you can achieve this by the following code, you have define the rotation angle from and to.
CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; [anim setToValue:[NSNumber numberWithFloat:0.0f]]; [anim setFromValue:[NSNumber numberWithDouble:M_PI/16]]; // rotation angle [anim setDuration:0.1]; [anim setRepeatCount:NSUIntegerMax]; [anim setAutoreverses:YES]; [[imageView layer] addAnimation:anim forKey:@"iconShake"];