layoutSubviews的觸發時機

  • init does not cause layoutSubviews to be called (duh)

init方法不會觸發

  • addSubview: causes layoutSubviews to be called on the view being added, the view it’s being added to (target view), and all the subviews of the target

addSubview在目標視圖被添加子視圖的時候觸發

  • view setFrame intelligently calls layoutSubviews on the view having its frame set only if the size parameter of the frame is different

view的frame發生變化的時候觸發

  • scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and its superview

scrollview和它的父視圖滾動的時候觸發

  • rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)

轉旋設備的時候,相應的視圖控制器對應的主視圖會觸發

  • Resizing a view will call layoutSubviews on its superview

改變視圖大小的時候會在視圖的父視圖上觸發

stackoverflow鏈接

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容