ios – CAKeyFrameAnimation在重复之前延迟

前端之家收集整理的这篇文章主要介绍了ios – CAKeyFrameAnimation在重复之前延迟前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个球形图像,我正在围绕一条路径制作动画.动画设置为永远重复,但为什么重复之间有延迟?

这是我的代码

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]

猜你在找的iOS相关文章