仿iOS图标抖动

来源:互联网 发布:浙江省网络文化节 编辑:程序博客网 时间:2024/05/16 07:59


?
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
31
32
33
34
35
#import "LHViewController.h"
#define angelToRandian(x)  ((x)/180.0*M_PI)
@interfaceLHViewController ()
@property(strong, nonatomic)IBOutletUIImageView *imageView;
 
@end
 
@implementationLHViewController
 
- (void)viewDidLoad
{
    [superviewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.
    UILongPressGestureRecognizer* longPress=[[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPress:)];
    [self.imageViewaddGestureRecognizer:longPress];
}
 
-(void)longPress:(UILongPressGestureRecognizer*)longPress
{
    if(longPress.state==UIGestureRecognizerStateBegan) {
        CAKeyframeAnimation* anim=[CAKeyframeAnimationanimation];
        anim.keyPath=@"transform.rotation";
        anim.values=@[@(angelToRandian(-7)),@(angelToRandian(7)),@(angelToRandian(-7))];
        anim.repeatCount=MAXFLOAT;
        anim.duration=0.2;
        [self.imageView.layeraddAnimation:animforKey:nil];
        self.btn.hidden=NO;
    }
}
 
- (IBAction)delete:(id)sender {
    [self.imageViewremoveFromSuperview];
    [self.btnremoveFromSuperview];
}
@end
0 0
原创粉丝点击