Skip to content

Instantly share code, notes, and snippets.

@dabing1022
Forked from nielsbot/ShakeAnimation.m
Last active August 29, 2015 14:25
Show Gist options
  • Save dabing1022/0ad79b6a8736e8d849b5 to your computer and use it in GitHub Desktop.
Save dabing1022/0ad79b6a8736e8d849b5 to your computer and use it in GitHub Desktop.

Revisions

  1. @nielsbot nielsbot revised this gist Apr 4, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ShakeAnimation.m
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,5 @@
    anim.repeatCount = 2.0f ;
    anim.duration = 0.07f ;

    [ viewToShake.layer addAnimation:anim forKey:@"nil" ] ;
    [ viewToShake.layer addAnimation:anim forKey:nil ] ;

  2. @nielsbot nielsbot created this gist Feb 21, 2012.
    13 changes: 13 additions & 0 deletions ShakeAnimation.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // this code will cause a UIView to shake--good for "login error"

    CAKeyframeAnimation * anim = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ;
    anim.values = [ NSArray arrayWithObjects:
    [ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0f, 0.0f, 0.0f) ],
    [ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0f, 0.0f, 0.0f) ],
    nil ] ;
    anim.autoreverses = YES ;
    anim.repeatCount = 2.0f ;
    anim.duration = 0.07f ;

    [ viewToShake.layer addAnimation:anim forKey:@"nil" ] ;