标签:
1 #import "NJViewController.h" 2 3 #define angle2Radian(angle) ((angle) / 180.0 * M_PI) 4 5 @interface NJViewController () 6 7 @property (weak, nonatomic) IBOutlet UIImageView *iconView; 8 @end 9 10 @implementation NJViewController 11 12 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 13 { 14 // 1.创建核心动画 15 CAKeyframeAnimation *keyAnima = [CAKeyframeAnimation animation]; 16 keyAnima.keyPath = @"transform.rotation"; 17 // 度数 / 180 * M_PI 18 keyAnima.values = @[@(-angle2Radian(4)), @(angle2Radian(4)), @(-angle2Radian(4))]; 19 20 keyAnima.removedOnCompletion = NO; 21 keyAnima.fillMode = kCAFillModeForwards; 22 keyAnima.duration = 0.1; 23 24 // 设置动画重复的次数 25 keyAnima.repeatCount = MAXFLOAT; 26 27 // 2.添加核心动画 28 [self.iconView.layer addAnimation:keyAnima forKey:nil]; 29 } 30 31 @end
标签:
原文地址:http://www.cnblogs.com/PJHome/p/5154874.html