问题描述
这是code我使用我的动画 CAShapeLayer
:
This is the code I’m using to animate my CAShapeLayer
:
_progressBarLayer.strokeEnd = CGFloat(_progressToDrawForProgress(progress))
let progressAnimation = CABasicAnimation(keyPath: "strokeEnd")
progressAnimation.duration = CFTimeInterval(1.0)
progressAnimation.fromValue = CGFloat(self.progress)
progressAnimation.toValue = _progressBarLayer.strokeEnd
progressAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
_progressBarLayer.addAnimation(progressAnimation, forKey: "progressAnimation")
我已经使用委托,看是否动画播放测试,它的作用。记录启动和停止在正确的地方。
I’ve tested using the delegate to see if the animation plays, and it does. Logging start and stop in the right place.
这code是在 setProgress(进度:CGFloat的,动画:布尔)。
功能并运行,如果动画是真的
This code is in a setProgress(progress: CGFloat, animated: Bool)
function and runs if animated is true.
有什么昭然若揭了吗?
推荐答案
龙答:事实证明,动画是不是在玩的东西,因为使用石英CAShapeLayer上述被吸引,所以我认为是的CAShapeLayer(即应该动画)竟是同层的石英图。
Long answer: It turns out that the animation wasn’t playing because of something being drawn above the CAShapeLayer using quartz, so what I thought was the CAShapeLayer (that should be animated) was actually a Quartz drawing of that same layer.
简短的回答:不要画到图形上下文与石英
Short answer: Don’t draw to the graphics context with Quartz
这篇关于CAShapeLayer的strokeEnd没有动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!