IOS第18天(7,CAKeyframeAnimation-图标抖动)

***

#import "HMViewController.h"

#define angle2radian(x) ((x) / 180.0 * M_PI)

@interface HMViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView; @end @implementation HMViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)]; [_imageView addGestureRecognizer:longPress];
} - (void)longPress:(UILongPressGestureRecognizer *)longPress
{
if (longPress.state == UIGestureRecognizerStateBegan) { CAKeyframeAnimation *anim = [CAKeyframeAnimation animation]; anim.keyPath = @"transform.rotation"; anim.values = @[@(angle2radian(-)),@(angle2radian()),@(angle2radian(-))]; anim.repeatCount = MAXFLOAT; anim.duration = 0.5; [_imageView.layer addAnimation:anim forKey:nil]; }
} @end
上一篇:开启关闭Centos的自动更新(转)


下一篇:CentOS 7 内核更新后删除旧内核(转载)