viewDidLayoutSubviews 与 layoutSubviews 调用顺序

了解演示demo的UI布局:

(lldb) po [[self view] recursiveDescription]

>

   | >

   |    | >

   |    |    | >


也即是:self.view 上添加个自定义的customView


打印调用的顺序:

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewDidLoad]

TestFunctionCall[49445:60b] ---> -[ZQCustomView initWithFrame:]

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewWillLayoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQRootViewController viewDidLayoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView layoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView layoutSubviews]

TestFunctionCall[49445:60b] ---> -[ZQCustomView drawRect:]


先调用试图控制器的viewWillLayoutSubviews 以及viewDidLayoutSubviews,然后调用view的layoutSubviews、layoutSubviews 。最后调用drawRect


你可能感兴趣的:(viewDidLayoutSubviews 与 layoutSubviews 调用顺序)