Question

I have been working on this for a few days with no luck... I am using Interface Builder to build the views. I have a UIButton with an image as the background. When I shake the iPhone, I want the button to wiggle. Any ideas?

Was it helpful?

Solution

Wobbling effect code here: how to create iphone's wobbling icon effect?.

There are examples of shake detection in Apple sample code so I won't repeat it here. You'll want to set a threshold for how hard you want it shaken (and maybe in what direction, if you care). Once it reaches that point then just trigger the routine that kicks off the animation effect. You may want to turn off shake detection once it's started and then turn it back on in the animation completion handler.

OTHER TIPS

I presume you'd have to change the CGRect defining the frame in which the button is drawn.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top