在向后播放CABasicAnimation后,CALayer消失
我有一个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
来向后播放animation时,
该图层在animation结束时消失:
circle.timeOffset = 1 circle.speed = -1 circle.beginTime = CACurrentMediaTime()
因此,我使用CADisplayLink向后播放animation,
但我想知道是否可以通过将速度设置为-1
并防止图层消失来实现。