title: Create an animation when changing the path of a subLayer to another path
body: <p>I have a <code>UIView</code> and its layer in which I added a CAShapeLayer as a subLayer with a path.</p>
  
  <p>When I tap on a <code>UIButton</code>, I change the path of the subLayer with another path.</p>
  
  <p>How can I animate this?</p>
  
  <p>Is it possible to have an animation as soon as the path changes?</p>
  
  <p>I tried to add:</p>
  
  <pre><code>let caAnimation = CABasicAnimation()
  caAnimation.keyPath = "path"
  caAnimation.duration = 2
  
  shapeLayer.addAnimation(caAnimation, forKey: "path")
  </code></pre>
  
  <p>in the <code>init(coder aDecoder: NSCoder)</code> method of my <code>UIView</code> in order to have an animation when the path is changed in <code>layoutSubviews()</code> method but it doesn't work.</p>
  
  <p>What did I do wrong?</p>
  
  <p>EDIT:</p>
  
  <p>I added a <code>fromValue</code> and <code>toValue</code> as parameters for the animation. I am wondering if I have to do that all the time or if there is a way to animate without specifying a <code>to</code> and <code>from</code> value and that it takes automatically the value before the change and the one after and make the animation.</p>