2
我试图动画这样的CAShapeLayer
path
性质的变化:动画CAShapeLayer通路改变
这是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")
}
但最终的结果是不是有什么我想要。我如何实现将图层的path
从旧值更改为新的动画?
这是它的外观,现在上面的代码:
你可以动画层的'strokeEnd'而不是改变的路径? – dan
这将启动从开始绘制的路径。我想动画只是沿着这条路走新旧路径的区别。 –