html5中文学习网

您的位置: 首页 > ios » 正文

仿iOS图标抖动_IOS开发

[ ] 已经帮助:人解决问题

   最近闲来无聊,研究了一下IPhone桌面图标的抖动,网上有一个类似的事例,但是我看来效果实在不佳,自己也来写一个玩玩,有需要的小伙伴可以参考下。GQWHTML5中文学习网 - HTML5先行者学习网

  仿iOS图标抖动GQWHTML5中文学习网 - HTML5先行者学习网

  ?GQWHTML5中文学习网 - HTML5先行者学习网

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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

  以上所述就是本文的全部内容了,希望大家能够喜欢。GQWHTML5中文学习网 - HTML5先行者学习网

(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助