Skip to content

Instantly share code, notes, and snippets.

@localshred
Created August 15, 2012 18:24
Show Gist options
  • Save localshred/3362147 to your computer and use it in GitHub Desktop.
Save localshred/3362147 to your computer and use it in GitHub Desktop.
View shake
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.08];
[animation setRepeatCount:3];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint:
CGPointMake([formContainer center].x - 20.0f, [formContainer center].y)]];
animation setToValue:[NSValue valueWithCGPoint:
CGPointMake([formContainer center].x + 20.0f, [formContainer center].y)]];
[[formContainer layer] addAnimation:animation forKey:@"position"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment