Springboard Style Wiggles
So you figured out how to setup a UILongPressGestureRecognizer and now you want to make a view "wiggle" back and forth similar to the iOS Springboard app. This is actually pretty simple with Core Animation.
First, setup the view you want to wiggle. The code below assumes it's called "view." I've found that setting kWiggleAnimationAngle to 0.04 works well.
In your gesture recognizer's handler:
We're also setting a few important properties:
- setting repeatCount to HUGE_VALF tells the animation to play indefinitely
- duration is the length of the animation (in one direction)
- autoreverses tells Core Animation to automatically play the animation in reverse once it's finished
Finally we add the animation to our view's layer and that's that. Well, sort of, when we're ready to stop the animation we need to do the following:
Resources: Apple's Core Animation Programming Guide, WWDC 2011 Videos, Almost There Stackoverflow Post
Note: I generally dislike in-app Springboards but sometimes they fit the bill.