Skip to content

Instantly share code, notes, and snippets.

@RuiAAPeres
Created January 16, 2014 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RuiAAPeres/8458663 to your computer and use it in GitHub Desktop.
Save RuiAAPeres/8458663 to your computer and use it in GitHub Desktop.
Animating a layer with transition to the right + changing the contents
CAAnimationGroup *animationsGroup = [CAAnimationGroup animation];
CATransition *t = [CATransition animation];
t.type = kCATransitionPush;
t.subtype = kCATransitionFromRight;
t.duration = 1.0f;
id currentContents = _layer.contents;
_layer.contents = (id)([UIImage imageNamed:@"image2.jpg"].CGImage);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"contents"];
animation.beginTime = t.beginTime;
animation.fromValue = currentContents;
animationsGroup.animations = @[t,animation];
animationsGroup.duration = 1.0f;
[_layer addAnimation:animationsGroup forKey:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment