iOS
[iOS] UIView 흔들기 효과
Naku
2011. 9. 28. 09:19
- (void)shakeView:(UIView*)targetView
{
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.05];
[animation setRepeatCount:6];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint: CGPointMake([targetView center].x - 10.0f, [targetView center].y)]];
[animation setToValue:[NSValue valueWithCGPoint: CGPointMake([targetView center].x + 10.0f, [targetView center].y)]];
[[targetView layer] addAnimation:animation forKey:@"position"];
}