(转)animationWithKeyPath

(转)animationWithKeyPath

转载自 zhujing0866

最近很常用 CAKeyframeAnimation 來製作動畫,但有時想找出 animationWithKeyPath 的值卻很困難,所以在這裡歸納一下:
transform.scale = 比例轉換
transform.scale.x = 闊的比例轉換
transform.scale.y = 高的比例轉換
transform.rotation.z = 平面圖的旋轉

opacity = 透明度

CABasicAnimation animationWithKeyPath Types

When using the ‘CABasicAnimation’ from the QuartzCore Framework in Objective-C, you have to specify an animationWithKeyPath.  This is a long string and is not easily listed in the CABasicAnimation, CAPropertyAnimation, or the CAAnimation class.  I ended up finding a handy chart within the Core Animation Programming guide in Apple’s iPhone OS Reference Library.  Hope this helps save someone time, at least it will for me.

View Code
 1 //The following code moves a view up 60 pixels and stops.
2
3 CABasicAnimation *theAnimation;
4 theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
5 theAnimation.delegate = self;
6 theAnimation.duration = 1;
7 theAnimation.repeatCount = 0;
8 theAnimation.removedOnCompletion = FALSE;
9 theAnimation.fillMode = kCAFillModeForwards;
10 theAnimation.autoreverses = NO;
11 theAnimation.fromValue = [NSNumber numberWithFloat:0];
12 theAnimation.toValue = [NSNumber numberWithFloat:-60];
13
14 [self.view.layer addAnimation:theAnimation forKey:@"animateLayer"];

This entry was posted on Monday, January 25th, 2010 at 2:53 pm and is filed under Objective-C, iPhone. You can follow any comments to this entry through the RSS 2.0 feed. You can leave a comment, or trackbackfrom your own site.

posted on 2012-03-06 15:57  east520  阅读(360)  评论(0)    收藏  举报

导航