Iphone - an easy way to get this click & # 8594; delete effects? or move & # 8594; move the viewing effect?

In iphone home, you can press and hold one app for 2 seconds, then everyone is shaking and waiting to remove or move.

How do I do this in my own view?

  • press and hold somewhere and each sub trembles

  • press and hold somewhere so the user can move views?

Like the iOS or ibook home screen, or quite a few other apps?

thank

+3
source share
2 answers

1) You will need to use UILongPressGestureRecognizer to detect long clicks

    UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startWobbling)];
[anyView addGestureRecognizer:longPressGesture];
[longPressGesture release];

startWobbling :

CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5.0));
CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5.0));


view.transform = leftWobble;  // starting point

[UIView beginAnimations:@"wobble" context:view];
[UIView setAnimationRepeatAutoreverses:YES]; // important
[UIView setAnimationRepeatCount:10];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)];

btn.transform = rightWobble; // end here & auto-reverse

[UIView commitAnimations];

2) . Apple: http://developer.apple.com/library/ios/#samplecode/Touches/Introduction/Intro.html

+6
+2

Source: https://habr.com/ru/post/1778933/


All Articles