如何声明CAKeyframeAnimation?

时间:2011-05-25 10:43:35

标签: iphone objective-c

我正在尝试沿预先定义的路径移动图像。我使用下面的代码。但它说的是:

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"];

1 个答案:

答案 0 :(得分:4)

您必须没有导入框架。导入它(请参阅this获取帮助)并将#import <QuartzCore/QuartzCore.h>添加到* .pch文件中。