2011-05-25 88 views
1

我試圖沿着預先定義的路徑移動圖像。我使用下面的代碼。但它說的東西是這樣的:如何聲明CAKeyframeAnimation?

CAKeyframeAnimation undeclared 
kCAAnimationPaced undeclared 

我是iPhone開發新手,請幫幫我。

*pathAnimation = [CAKeyframeAnimationanimationWithKeyPath:@"position"]; 
pathAnimation.duration = 1.0f; 
pathAnimation.calculationMode = kCAAnimationPaced; 
pathAnimation.fillMode = kCAFillModeForwards; 
pathAnimation.removedOnCompletion = NO; 

CGMutablePathRef pointPath = CGPathCreateMutable(); 
CGPathMoveToPoint(pointPath, NULL, 492, 128); 
CGPathAddLineToPoint(pointPath, NULL, 480, 150); 
CGPathAddLineToPoint(pointPath, NULL, 489, 160); 
CGPathAddLineToPoint(pointPath, NULL, 489, 180); 
pathAnimation.path = pointPath; 
CGPathRelease(pointPath); 

[imageview.layer addAnimation:pathAnimation forKey:@"pathAnimation"]; 

回答

4

您必須沒有導入框架。導入它(請參閱this尋求幫助)並將#import <QuartzCore/QuartzCore.h>添加到* .pch文件中。