Skip to content

Instantly share code, notes, and snippets.

@jeksys
Created March 2, 2012 20:21
Show Gist options
  • Save jeksys/1961023 to your computer and use it in GitHub Desktop.
Save jeksys/1961023 to your computer and use it in GitHub Desktop.
Key Frame Animation
-(IBAction)buttonPress:(id)sender
{
NSString *keyPath = @"anchorPoint.x";
CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:keyPath];
[kfa setValues:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:-.05],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.1],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.05],
nil]];
[kfa setAdditive:YES];
[kfa setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[kfa setDuration:.35];
[button.layer addAnimation:kfa forKey:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment