0

( CABasicAnimation(keyPath = "position.x") )使用 40 张图像创建了动画。每张图像持续时间为 3 秒。因此,在 CALayer 中,核心动画的总持续时间为 120 秒。
我正在使用 UISlider 执行搜索操作。例如,当滑块值为 5 时,我需要显示恰好在 5 秒内出现/将出现的图像并继续核心动画。如何在核心动画内部进行正向和反向寻道操作?

这是我的动画代码

let animation = CABasicAnimation()
animation.keyPath = "position.x"
animation.fromValue = -viewSize.width
animation.toValue =  (viewSize.width)/2
animation.duration = 3
animation.speed = 1 // 1 is default actually
animation.beginTime = CACurrentMediaTime() + animationTimes[index-1] // here animationTimes is array like [0,3,6,9 ...... so on]
animation.fillMode = CAMediaTimingFillMode.forwards
animation.isRemovedOnCompletion = false
blackLayer.add(animation, forKey: "basic"). // here per blackLayer contain individual imageLayer and animation             
parentLayer.addSublayer(blackLayer)
4

0 回答 0