我一直在試圖實現這一點,但找不到任何代碼,可以搖動它像iPhone應用程序在刪除它們時動搖!如何把搖動動畫放在uiimageview上?
CABasicAnimation *animation =
[CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.05];
[animation setRepeatCount:8];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x - 20.0f, [lockView center].y)]];
[animation setToValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x + 20.0f, [lockView center].y)]];
[[lockView layer] addAnimation:animation forKey:@"position"];
看到這個答案,它可以幫助你:http://stackoverflow.com/questions/1632364/shake-visual-effect-on-iphone -not-shaking-the-device – pbibergal