CAKeyFrameAnimation delays before repeating

animation, cakeyframeanimation, delay, geometry, ios

Solution

Try this:

[animation setCalculationMode:kCAAnimationPaced]

Problem

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); ```

Original source