和一般动画不同的是,使用Masonry这样放入到动画的block中不能直接让动画生效,只是直接造成控件位移,经过尝试,应当添加如下操作
和一般动画不同的是,使用Masonry这样放入到动画的block中不能直接让动画生效,只是直接造成控件位移,经过尝试,应当添加如下操作
//放在主线程中
dispatch_async(dispatch_get_main_queue(), ^{
//告知需要更改约束
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:0.3 animations:^{
[self.animateView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(0);
}];
//告知父类控件绘制,不添加注释的这两行的代码无法生效
[self.animateView.superview layoutIfNeeded];
}];
});