You can do something like,
Define radians to convert degrees into radians
#define RADIANS(degrees) (((degrees) * M_PI) / 180.0)
then in your viewDidAppear
,
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
CGAffineTransform leftTransform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-10.0));
CGAffineTransform rightTransform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(10.0));
_myView.transform = leftTransform; //Here `_myView` is the your view on which you want animations!
[UIView beginAnimations:@"youCanSetAnimationIdHere" context:(__bridge void * _Nullable)(_myView)];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:5];
[UIView setAnimationDuration:0.25];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationCompletedWithAnimationId:isCompleted:view:)];
_myView.transform = rightTransform;
[UIView commitAnimations];
}
and your animationCompletedWithAnimationId
method should be like,
- (void) animationCompletedWithAnimationId:(NSString *)animationID isCompleted:(NSNumber *)isCompleted view:(UIView *)view
{
if ([isCompleted boolValue]) {
UIView *myView = view;
myView.transform = CGAffineTransformIdentity;
}
}
And the result is

You can change repeat count and radians as per your requirement !