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
這將啓動從開始繪製的路徑。我想動畫只是沿着這條路走新舊路徑的區別。 –