IOS-like icon Jitter

Source: Internet
Author: User

IOS-like icon Jitter

I 've been bored recently and studied the IPhone desktop icon jitters. There is a similar online example, but I think the effect is really poor. I also want to write something for fun, if you have any need, refer.

IOS-like icon Jitter

?

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)/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

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.