Skip to content

Instantly share code, notes, and snippets.

@kaiix
Created December 5, 2012 05:03
Show Gist options
  • Select an option

  • Save kaiix/4212439 to your computer and use it in GitHub Desktop.

Select an option

Save kaiix/4212439 to your computer and use it in GitHub Desktop.
UIView shake animation
- (void)shake {
CAKeyframeAnimation * anim = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ;
anim.values = @[
[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0f, 0.0f, 0.0f) ],
[NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0f, 0.0f, 0.0f)]];
anim.autoreverses = YES ;
anim.repeatCount = 2.0f ;
anim.duration = 0.07f ;
[self.layer addAnimation:anim forKey:nil ] ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment