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 }

 

 
 
 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。