0

I have a keyframeAnimation and I define a Path, but the animation doesn't work.

Do you see anything wrong? :S

Here is the code:

CAKeyframeAnimation *animKF = [CAKeyframeAnimation animationWithKeyPath:@"position"];

CGMutablePathRef animationPath = CGPathCreateMutable();

CGPathMoveToPoint(animationPath, NULL, 300, 100);

CGPathAddArcToPoint(animationPath, NULL, 300, 100, 800, 500, 500);

animKF.path = animationPath;

animKF.duration = 3;

animKF.rotationMode =  kCAAnimationRotateAuto;

[imageView.layer addAnimation:animKF forKey:@"keyframe"];

Thank you so much

torhector2
  • 443
  • 1
  • 5
  • 19

1 Answers1

0

You might think that CGPathMoveToPoint() is the method that actually "moves" the point, sorry that's not the case. I guess what you intended is to animate "path" property. Hence you should create several (in your case, 3) CGMutablePathRef objects as keyframe. Then call

[animKF setValues: @[path1,path2,path3]];
Philip007
  • 3,190
  • 7
  • 46
  • 71