Kar*_*lis 6 core-animation ios swift
我试图动画这样的path属性变化CAShapeLayer:
animatePathChange(for: progressLayer, toPath: progressPath.cgPath)
progressLayer.path = progressPath.cgPath
Run Code Online (Sandbox Code Playgroud)
这是animatePathChange功能代码:
func animatePathChange(for layer: CAShapeLayer, toPath: CGPath) {
let animation = CABasicAnimation(keyPath: "path")
animation.duration = 1.0
animation.fromValue = layer.path
animation.toValue = toPath
animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
layer.add(animation, forKey: "path")
}
Run Code Online (Sandbox Code Playgroud)
但最终结果不是我想要的.如何实现将图层path从旧值更改为新值的动画?
现在看看它是如何使用上面的代码:
mat*_*att 19
不要在路径上制作动画.配置整个路径,然后设置strokeEnd- 让我们说它是0,所以用户什么都看不到.现在每次你想做出改变,动画从当前的变化strokeEnd,以新的strokeEnd.该路径似乎在曲线周围进一步延伸.
| 归档时间: |
|
| 查看次数: |
5470 次 |
| 最近记录: |