动画问题,和普通的方法实现差不多,重点只是修改约束后调用
[view.superview layoutIfNeeded];
而已
[view mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(400);
make.left.mas_equalTo(100);
make.size.mas_equalTo(CGSizeMake(100, 100));
}];
[view.superview layoutIfNeeded];
//如果其约束还没有生成的时候需要动画的话,就请先强制刷新后才写动画,否则所有没生成的约束会直接跑动画
[UIView animateWithDuration:3 animations:^{
[view mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(200);
}];
[view.superview layoutIfNeeded];//强制绘制
注意此处一定是改变约束的父视图
调用layoutIfNeeded
函数
- (void)tapTeacherVideoView {
if (self.isTeacherSplitScreen) {
[self.studentVideoView removeFromSuperview];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.5f];
[self.teacherVideoView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.leading.equalTo(self.view);
}];
[self.view layoutIfNeeded];
[UIView commitAnimations];
self.teacherSplitScreen = NO;
}
}