关于更新约束
2017-07-04 本文已影响11人
Demonboy
- (void)viewDidLoad {
[superviewDidLoad];
//在更新约束时,要调用:
//告诉self.view约束需要更新使用这个方法会走- (void)updateViewConstraints这个方法
[self.view setNeedsUpdateConstraints];
//调用此方法告诉self.view检查是否需要更新约束若需要则更新下面添加动画效果才起作用
[self.view updateConstraintsIfNeeded];
[UIView animateWithDuration:0.25 animations:^{
[self.view layoutIfNeeded];
}];
}
//苹果推荐在updateViewConstraints方法中更新或者添加约束
- (void)updateViewConstraints
{
[super updateViewConstraints];
}