iOS开发:AutoLayout关于更新的几个方法

来源:互联网 发布:centos 软件选择 编辑:程序博客网 时间:2024/05/17 04:16
  • (void)layoutSubviews
  • (void)setNeedsLayout
  • (void)layoutIfNeeded
  • (void)updateConstraints
  • (void)setNeedsUpdateConstraints
  • (void)updateConstraintsIfNeeded

layoutSubviews
系统重写布局,不能直接调用
setNeedsLayout
标记为需要重新布局,异步调用layoutIfNeeded刷新布局,不立即刷新,但layoutSubviews一定会被调用
layoutIfNeeded
需要刷新的标记,立即调用layoutSubviews进行布局
updateConstraints
自定义视图设置约束时重写这个方法,注意:[super updateConstraints]最后调用
setNeedsUpdateConstraints
当一个自定义view的某个属性发生改变,并且可能影响到constraint时,需要调用此方法去标记constraints需要在未来的某个点更新,系统然后调用updateConstraints.
updateConstraintsIfNeeded
立即触发约束更新
0 0
原创粉丝点击