Where to get frame size of custom UIView in its subclass

后端 未结 3 1533
一整个雨季
一整个雨季 2021-02-05 11:24

When does the correct frame size of the UIView is calculated when I add my custom UIView by using storyboard? I can\'t get correct frame size in UIView\'s

3条回答
  •  执念已碎
    2021-02-05 11:53

    Since viewDidLayoutSubviews() is getting called multiple times, I'd recommend using the viewDidAppear() delegate.

    viewDidLoad() is called before any frame was set.

    viewDidLayoutSubviews() is called during frame sizing and will be called multiple times with different frame sizes (usually frameZero before a frame is calculated).

    viewDidAppear() All frames are set.

提交回复
热议问题