ios开发——实用技术篇&三维旋转动画

实现三位旋转动画的方法有很多种,这里介绍三种

一:UIView

复制代码
1     [UIView animateWithDuration:1.0 animations:^{
2         self.iconView.layer.transform = CATransform3DMakeRotation(M_PI_2, 0, 1, 0);
3     } completion:^(BOOL finished) {
4         self.iconView.image = [UIImage imageNamed:@"user_defaultgift"];
5        
6         [UIView animateWithDuration:1.0 animations:^{
7             self.iconView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 1, 0);
8         }];
9     }];
复制代码

二:CATransition自定义

1     CATransition
2     CATransition *anim = [CATransition animation];
3     anim.duration = 1.0;
4     anim.type = @"rippleEffect";
5     [self.iconView.layer addAnimation:anim forKey:nil];

三:CATransition

复制代码
 1     
 2     [UIView transitionWithView:self.iconView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
 3         self.iconView.image = [UIImage imageNamed:@"user_defaultgift"];
 4     } completion:^(BOOL finished) {
 5         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
 6             [UIView transitionWithView:self.iconView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
 7                 self.iconView.image = [UIImage imageNamed:@"default_avatar"];
 8             } completion:nil];
 9         });
10     }];
11 }
复制代码
posted @ 2017-04-30 20:48  余磊  阅读(512)  评论(0编辑  收藏  举报
友情链接:回力旗舰店 | 中老年女装 | 新航道 | 托福培训 | 雅思报名费用