Where to determine UIView size

后端 未结 3 1578
暗喜
暗喜 2021-02-01 04:03

Summary: How should the UIViewController know the size of its UIView instance when initialising that view?

The dedicated initialisation method for an UIView

3条回答
  •  一向
    一向 (楼主)
    2021-02-01 04:29

    You don't have to use the designated initializer. Just use init as in [[UIView alloc] init]. The designated initializer has to be used from subclasses' initializers.

    On the other hand, setting the frame twice should not do much harm. Performing a lot of tasks in setFrame: is unusual. Layouting is normally done in layoutSubviews and is only performed once.

提交回复
热议问题