The easiest way I know is to use Core Animation. Basically, you create a basic animation block, then perform a rotation transformation, and also set and repeat the counter. Core Animation then takes care of everything you need for this swing effect.
To start the Core Animation block, simply do:
[UIView beginAnimations:@"any string as animationID" context:self]; [UIView setAnimationRepeatCount:10];
not verified. But there may be something you also have to do:
[UIView setAnimationBeginsFromCurrentState:YES]
AFAIK setAnimationRepeatCount will have the effect that the animation is done, canceled, done, canceled, done, canceled, done ... as many times as you specify. Thus, you can first turn left without recounting, and then from this moment begin to oscillate with repetition. When this is done, you can turn back to identity transformation (= no rotation and scaling applied).
You can bind the animation by setting the animation delegate with
[UIView setAnimationDelegate:self]
and then
[UIView setAnimationDidStopSelector:@selector(myMethod:finished:context:)]
and as soon as the animation stops, this method will be called. See the UIView class documentation for how to implement this method, which will be called when the animation stops. Basically, inside this method, you should perform the next step (for example, reverse rotation or something else), with a new animation block, but with the same context and animation identifier, and then (if necessary) specify a different didStopSelector file.
UPDATE:
You can check:
[UIView setAnimationRepeatAutoreverses:YES]
it will oscillate back and forth automatically.