Pages

Labels

Thursday, July 5, 2012

Shake Animation in xcode

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
    [animation setDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];
    [animation setDuration:0.05];
    [animation setRepeatCount:4];
    [animation setAutoreverses:YES];
    [animation setFromValue:[NSValue valueWithCGPoint:
                             CGPointMake([v center].x - 14.0f, [v center].y)]];
    [animation setToValue:[NSValue valueWithCGPoint:
                           CGPointMake([v center].x + 14.0f, [v center].y)]];
    [[v layer] addAnimation:animation forKey:@"position"];

0 comments:

Post a Comment

 
Loading