코딩하는 나귀

- (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"];

}