今天图老师小编要跟大家分享仿iOS图标抖动,精心挑选的过程简单易学,喜欢的朋友一起来学习吧!
【 tulaoshi.com - 编程语言 】
仿iOS图标抖动
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)#import "LHViewController.h"#define angelToRandian(x) ((x)/180.0*M_PI)@interface LHViewController ()@property (strong, nonatomic) IBOutlet UIImageView *imageView;@end@implementation LHViewController- (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:)]; [self.imageView addGestureRecognizer:longPress];}-(void)longPress:(UILongPressGestureRecognizer*)longPress{ if (longPress.state==UIGestureRecognizerStateBegan) {CAKeyframeAnimation* anim=[CAKeyframeAnimation animation];anim.keyPath=@"transform.rotation";anim.values=@[@(angelToRandian(-7)),@(angelToRandian(7)),@(angelToRandian(-7))];anim.repeatCount=MAXFLOAT;anim.duration=0.2;[self.imageView.layer addAnimation:anim forKey:nil];self.btn.hidden=NO; }}- (IBAction)delete:(id)sender { [self.imageView removeFromSuperview]; [self.btn removeFromSuperview];}@end
以上所述就是本文的全部内容了,希望大家能够喜欢。
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)来源:http://www.tulaoshi.com/n/20160219/1597940.html