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

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

一:UIView

ios开发——实用技术篇&三维旋转动画
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 }];
ios开发——实用技术篇&三维旋转动画

二: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

ios开发——实用技术篇&三维旋转动画
 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 }
ios开发——实用技术篇&三维旋转动画
上一篇:Android旋转动画


下一篇:android旋转动画的两种实现方式