我有一个 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
并防止该层消失。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)