动画:
更新控件的位置 layoutIfNeeded 会立即对其控件进行更新
更新约束:mas_updataConstraints 更新约束关键词
实现动画移动:使用NSTimer定时器 每隔一段时间进行位移移动
//原始位置 移动到 右上角, 并且变小. 动画结束以后打印
- (void)moveToRightTop{
[UIView animateWithDuration:6 animations:^{
[self.imageViewmas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.right.mas_equalTo(0);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
// 如果有需要,要更新位置
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
NSLog(@"动画结束后,自动执行这里的方法");
}];
}
//从原始位置 跑到右下角, 跑到右下角以后,再跑回来,如此反复
- (void)reverseAnimate{
//duration:持续时间
//delay:延迟操作
//options:是枚举类型,表示动画的展现方式
//Repeat:重复动画,
//Autoreverse:反向动画
//:Linear线性
[UIView animateWithDuration:4 delay:0options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionCurveLinearanimations:^{