Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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