CALayer disappears after playing CABasicAnimation back

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.

+3
ios swift core-animation calayer cabasicanimation
Jul 10 '16 at 13:03
source share

No one has answered this question yet.

See similar questions:

55
Animation recovery when it stopped, when the application resumes from the background

or similar:

129
Disabling implicit animations in - [CALayer setNeedsDisplayInRect:]
17
replacing CALayer and CABasicAnimation with SKScene and SKActions
17
CABasicAnimation with CALayer does not animate
3
Selective Override of CALayer Hidden Animations
one
CABasicAnimation reverse (back)
one
CALayer CABasic
one
Swift - CABasicAnimation does not work with CALayer
0
Is the practice of CABasicAnimation different for user interface objects and CALayers?
0
CAAnimation redraw
0
UIView affine scaling transformation is not animating properly in both directions



All Articles