UIView动画的第一种
// 1.动画
// 参数一:动画的播放时长
// 参数二:把要实现的动画效果,放到block里去完成
// [UIView animateWithDuration:2 animations:^{
// self.myView.frame = CGRectMake(100, 100, 150, 150);
self.myView.backgroundColor = [UIColor cyanColor];
self.myView.alpha = 0;
// }];
第二种
// [UIView animateWithDuration:2 animations:^{
// self.myView.frame = CGRectMake(100, 100, 150, 100);
// } completion:^(BOOL finished) {
// self.myView.backgroundColor = [UIColor cyanColor];
// [UIView animateWithDuration:2 animations:^{
// self.myView.frame = CGRectMake(100, 100, 150, 0);
// }];
// }];
第三种
// UIView的第三种动画
// 参数二:延时多久执行
// [UIView animateWithDuration:2 delay:0.1 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{
// self.myView.frame = CGRectMake(100, 100, 150, 200);
// } completion:^(BOOL finished) {
// [UIView animateWithDuration:2 animations:^{
// self.myView.frame = CGRectMake(100, 100, 150, 0);
// }];
//
// }];
第四种
// UIView的第四种动画
// 下弹
// 参数3:震动的幅度,越小越大
// 参数4:初始速度,越快越大
[UIView animateWithDuration:2 delay:0.1 usingSpringWithDamping:0.1 initialSpringVelocity:10 options:UIViewAnimationOptionRepeat animations:^{
self.myView.frame = CGRectMake(100, 100, 150, 150);
} completion:^(BOOL finished) {
}];