I have a CALayer and I added a CABasicAnimation for it as follows:
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)
When I play the animation back by setting the layer speed to -1 ,
the layer disappears at the end of the animation:
circle.timeOffset = 1 circle.speed = -1 circle.beginTime = CACurrentMediaTime()
Because of this, I use CADisplayLink to play back the animation,
but I wonder if this can be done by setting the speed to -1 and also preventing the layer from disappearing.
ios swift core-animation calayer cabasicanimation
Viktor Simkรณ Jul 10 '16 at 13:03 2016-07-10 13:03
source share