gpt4 book ai didi

ios - CAShapeLayer 的 strokeEnd 没有动画

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:17:00 28 4
gpt4 key购买 nike

这是我用来为我的 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")

我已经使用委托(delegate)进行了测试,看看动画是否播放,确实如此。记录在正确的位置开始和停止。

此代码位于 setProgress(progress: CGFloat, animated: Bool) 函数中,如果 animated 为真则运行。

这里有什么明显的东西吗?

最佳答案

长答案:原来动画没有播放是因为使用 quartz 在 CAShapeLayer 上方绘制了一些东西,所以我认为 CAShapeLayer(应该是动画的)实际上是同一层的 Quartz 绘图。

简短回答:不要使用 Quartz 绘制图形上下文

关于ios - CAShapeLayer 的 strokeEnd 没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29056332/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com