I need to create a rotation animation for a uiimageview. The best analogy I can think of is a picture hanging on a wall. The nail that holds up the picture is placed at the top of the picture.
If I pushed the picture I want to model the slight swinging motion of the picture back and forth until it eventually reverts back its its starting position.
I know I’ll first have to start by changing the view’s anchor point but I’m unsure how to approach the rest of the problem. I could use CABasicAnimation but I’m guessing that would be ridiculously complex/overkill to get a relatively simple animation.
Any suggestions?
[EDIT]
This answer actually worked for me nicely using blocks 🙂
I don’t think it should be too difficult using
CABasicAnimationto animate thetransform.rotationproperty and choosing the right timing function. Something along the lines of:The key point is choosing the right timing function; if none of the predefined ones are ok, you can define an arbitrary timing function using
+ (id)functionWithControlPoints:(float)c1x :(float)c1y :(float)c2x :(float)c2y(where the control point define a bezier curve).