Created
February 13, 2012 09:49
-
-
Save meiwin/1815541 to your computer and use it in GitHub Desktop.
CALayer animation (the correct way)
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
// sample codes for animating calayer's opacity | |
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; | |
animation.fromValue = [NSNumber numberWithValue:0]; | |
animation.toValue = [NSNumber numberWithValue:1]; | |
targetLayer.opacity = 1; // must be set, otherwise targetLayer opacity will not be updated, even after animation is completed. | |
[targetLayer addAnimation:animation forKey:@"opacity"]; // the key "opacity" must match keyPath being animated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment