手机
当前位置:查字典教程网 >编程开发 >IOS开发 >仿iOS图标抖动
仿iOS图标抖动
摘要:仿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图片放大的方式(transform和frame)

iOS开发之手动布局子视图

浅析iOS给图片加水印的方法

详解IOS图层转场动画

IOS仿今日头条滑动导航栏

iOS实现富文本编辑器的方法详解

iOS开发之路--微博骨架搭建

微信支付开发IOS图文教程案例

iOS中的UITextView文字输入光标使用技巧小结

详解IOS图片压缩处理

精品推荐
分类导航