We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
和约束一样,布局分为自动更新布局和手动更新布局,自动更新布局会在如下场景下发生:
1、init初始化不会触发layoutSubviews,但是用initWithFrame进行初始化的时候,当rect的值不是CGRectZero时也会触发 2、addSubview会触发layoutSubviews。 3、设置view的frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化。 4、改变一个UIView大小的时候也会触发父UIView上的layoutSubviews事件。 5、滚动一个UIScrollView会触发layoutSubviews。 6、旋转屏幕会触发父UIView上的layoutSubviews事件。
如果我们需要手动更新布局可以调用:
- (void)setNeedsLayout;
这样会在RunLoop进入休眠之前更新布局,如果想要立刻生效,可以调用:
- (void)layoutIfNeeded;
当更新布局的时候
- (void)layoutSubviews;
方法将会被触发。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
和约束一样,布局分为自动更新布局和手动更新布局,自动更新布局会在如下场景下发生:
如果我们需要手动更新布局可以调用:
- (void)setNeedsLayout;
这样会在RunLoop进入休眠之前更新布局,如果想要立刻生效,可以调用:
- (void)layoutIfNeeded;
当更新布局的时候
- (void)layoutSubviews;
方法将会被触发。
The text was updated successfully, but these errors were encountered: