Apple doc regarding viewDidLayoutSubviews
says:
When the bounds change for a view controller's view, the view adjusts the positions of its subviews and then the system calls this method. However, this method being called does not indicate that the individual layouts of the view's subviews have been adjusted. Each subview is responsible for adjusting its own layout.
Your view controller can override this method to make changes after the view lays out its subviews. The default implementation of this method does nothing.
I have view1
which contains view2
means view2
is a subview of view1
. I am creating a CALayer
for my view2
which I want to be exact size of view2
. I am using auto layouts
so I want to create the CALayer
when auto layout
finish its work so I can have correct values to set for CALayer
frame.
But in viewDidLayoutSubviews
method I can't detect when exactly view2
frame is set by auto layout
because Apple doc is also saying that
this method being called does not indicate that the individual layouts of the view's subviews have been adjusted.
after that Apple doc saying
Your view controller can override this method to make changes after the view lays out its subviews.
I am so confused at what point auto layout
will set view2
frame so I can set my CALayer
frame accordingly.