Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CAKeyFrameAnimation delays before repeating

I have an ball image that I'm animating around a path. The animation is set to repeat forever, but why is there a delay between repeats?

Here's my code:

CGPathRef aPath;
aPath = CGPathCreateWithEllipseInRect(CGRectMake(0, 0, SIZE, SIZE), NULL);

[CATransaction begin];

arcAnimation = [CAKeyframeAnimation animationWithKeyPath: @"position"];
[arcAnimation setBeginTime:CACurrentMediaTime()];
[arcAnimation setDuration: 1.5];
[arcAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
[arcAnimation setAutoreverses: NO];
[arcAnimation setRepeatCount:HUGE_VALF];
arcAnimation.removedOnCompletion = NO;
arcAnimation.fillMode = kCAFillModeRemoved;
[arcAnimation setPath: aPath];
[ball.layer addAnimation: arcAnimation forKey: @"position"];
[CATransaction commit];
CFRelease(aPath);
like image 456
Kelly Bennett Avatar asked Feb 01 '13 18:02

Kelly Bennett


1 Answers

Try this:

[animation setCalculationMode:kCAAnimationPaced]
like image 157
haho Avatar answered Oct 05 '22 02:10

haho