Skip to content

Instantly share code, notes, and snippets.

@codeswimmer
Created January 2, 2013 19:55
Show Gist options
  • Select an option

  • Save codeswimmer/4437390 to your computer and use it in GitHub Desktop.

Select an option

Save codeswimmer/4437390 to your computer and use it in GitHub Desktop.
iOS: Animate an object to move
CABasicAnimation *myAnimation;
myAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
myAnimation.duration=1;
myAnimation.repeatCount=2;
myAnimation.autoreverses=YES;
myAnimation.fromValue=[NSNumber numberWithFloat:0];
myAnimation.toValue=[NSNumber numberWithFloat:-50];
[view.layer addAnimation:myAnimation forKey:@"animateLayer"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment