仿iOS图标抖动_IOS开发教程-查字典教程网
仿iOS图标抖动
仿iOS图标抖动
发布时间:2016-12-28 来源:查字典编辑
摘要:仿iOS图标抖动#import"LHViewController.h"#defineangelToRandian(x)((x)/180.0*...

仿iOS图标抖动

#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

以上所述就是本文的全部内容了,希望大家能够喜欢。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新IOS开发学习
    热门IOS开发学习
    编程开发子分类