类似长按图标抖动一样
#define RADIANS(degrees) ((degrees * M_PI) / 180.0)
CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-1.0));
CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(1.0));
self.view.transform = leftWobble;
[UIView beginAnimations:@"wobble" context:self.view];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:10];
[UIView setAnimationDuration:0.08];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(wobbleEnded:finished:context:)];
self.view.transform = rightWobble;
[UIView commitAnimations];
- (void) wobbleEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([finished boolValue])
{
UIView* item = (UIView *)context;
item.transform = CGAffineTransformIdentity;
}
}