我有一个CALayer,我已经像这样添加了一个CABasicAnimation:
circle = CALayer()
circle.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
circle.backgroundColor = UIColor.green().cgColor
circle.cornerRadius = 50
circle.speed = 0
view.layer.addSublayer(circle)
animation = CABasicAnimation(keyPath: "position")
animation.duration = 1
animation.fromValue = NSValue(cgPoint: CGPoint(x: 50, y: 50))
animation.toValue = NSValue(cgPoint: CGPoint(x: view.bounds.width / 2, y: view.bounds.height / 2))
animation.fillMode = kCAFillModeBoth
animation.isRemovedOnCompletion = false
circle.add(animation, forKey: nil)
当我通过将图层的速度设置为-1
来向后播放动画时,
图层在动画结束时消失:
circle.timeOffset = 1
circle.speed = -1
circle.beginTime = CACurrentMediaTime()
因此,我使用CADisplayLink向后播放动画,
但是我想知道是否可以通过将速度设置为-1
并防止图层消失来实现。