实现动画的方法,一般都是使用以下方法
[UIView animateWithDuration:0.2 animations:^{
}];
注:
1.当使用frame布局的时候这个方法只需要在回调内部改变要出现动画的view类的frame就可以了.
2.当使用masonry的时候,需要多一步操作.代码如下:比如,lineView需要出现动画,首先要做的是更新lineView的布局,然后再使用动画方法,但是需要调用一次layoutIfNeeded方法,至于调用的对象,一般设置为lineView的直接父控件.
[self.lineView mas_updateConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(leftSpace); }]; [UIView animateWithDuration:0.2 animations:^{ [self layoutIfNeeded];//当前控件的父视图调用 }];