GithubHelp home page GithubHelp logo

subclass CardImageView의 사이즈는 속성으로 고정하고 VC에서 origin만 부여하여 생성하는 방법 about swift-cardgameapp HOT 1 CLOSED

jinios avatar jinios commented on August 25, 2024
subclass CardImageView의 사이즈는 속성으로 고정하고 VC에서 origin만 부여하여 생성하는 방법

from swift-cardgameapp.

Comments (1)

jinios avatar jinios commented on August 25, 2024

A. (JK의 코멘트와 나의 의견을 조합해서 생각해본 답변)

  • convenience이 init내에 CGSize값을 고정해놓으면 물론 질문대로 사용할 수도 있다.
  • 하지만 frame은 superview를 기준으로 구하는 origin이 필요한 값이기때문에, frame자체를 스스로 계산할 수는 없다. fix된 사이즈를 subview가 갖고있다고해도 슈퍼뷰에서 위치를 지정해주는 코드를 작성해야하기때문에, 꼭 저 방법이 더 효율적이라고 할 수는 없다. 특히 superView를 관리하는 ViewController의 코드가 더 짧아진다는 것은 해당 방법을 사용했을때 따라오는 장점이라고 하기엔 애매한 부분이 있다.
  • 어차피 frame은 superview를 기준으로 구하는 값이기때문에 superview에서 subview로 추가할 UIView를 만들면서 속성을 지정하는게 더 자연스럽다.

from swift-cardgameapp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.