/
iOS AutoLayout - get frame size width

iOS AutoLayout - get frame size width

The answer is

 [view layoutIfNeeded];

Solution

  • Place that code in viewDidAppear

Reason

  • viewDidLoad happens before autolayout is completed. So the position is not yet set by autolayout that was specified in xib
  • viewDidAppear happens after autolayout is completed.

Related content

NSLayoutConstraint-代码实现自动布局的函数用法说明
NSLayoutConstraint-代码实现自动布局的函数用法说明
More like this
UIGetScreenImage
UIGetScreenImage
More like this
Image Dimension
Image Dimension
More like this
UIEdgeInsets
UIEdgeInsets
More like this
UIColor to UIImage
UIColor to UIImage
More like this
PCH was compiled with module cache
PCH was compiled with module cache
More like this