Created
January 16, 2014 16:56
-
-
Save RuiAAPeres/8458663 to your computer and use it in GitHub Desktop.
Animating a layer with transition to the right + changing the contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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