我有一个球形图像,我正在围绕一条路径制作动画.动画设置为永远重复,但为什么重复之间有延迟?
这是我的代码:
CGPathRef aPath; aPath = CGPathCreateWithEllipseInRect(CGRectMake(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);
解决方法
试试这个:
[animation setCalculationMode:kCAAnimationPaced]