码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发动画(Animation)图片360度不停旋转

时间:2016-05-05 19:17:45      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:

 

 

 1 {
 2     CGFloat angle;
 3 }
 4 
 5 - (void)viewDidLoad {
 6     [super viewDidLoad];
 7     angle = 0;
 8     [self startAnimation];
 9 }
10 
11 //方法1
12 -(void) startAnimation
13 {
14     [UIView beginAnimations:nil context:nil];
15     [UIView setAnimationDuration:0.01];
16     [UIView setAnimationDelegate:self];
17     [UIView setAnimationDidStopSelector:@selector(endAnimation)];
18     self.scanImage.transform = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
19     [UIView commitAnimations];
20 }
21 
22 -(void)endAnimation
23 {
24     angle += 2;
25     [self startAnimation];
26 }
27 
28 //方法2
29 - (void)startAnimation
30 {
31     CGAffineTransform endAngle = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
32     
33     [UIView animateWithDuration:0.01 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
34         self.scanImage.transform = endAngle;
35     } completion:^(BOOL finished) {
36         angle += 2; [self startAnimation];
37     }];
38 }

 

iOS开发动画(Animation)图片360度不停旋转

标签:

原文地址:http://www.cnblogs.com/codemakerhj/p/5462618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!