I have a UIView and its layer in which I added a CAShapeLayer as a subLayer with a path.
When I tap on a UIButton, I change the path of the subLayer with another path.
How can I animate this?
Is it possible to have an animation as soon as the path changes?
I tried to add:
let caAnimation = CABasicAnimation()
caAnimation.keyPath = "path"
caAnimation.duration = 2
shapeLayer.addAnimation(caAnimation, forKey: "path")
in the init(coder aDecoder: NSCoder) method of my UIView in order to have an animation when the path is changed in layoutSubviews() method but it doesn't work.
What did I do wrong?
Aucun commentaire:
Enregistrer un commentaire