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链接

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容