title: Animating CALayer background color and update model value
body: <p>I want to animate a <code>backgroundColor</code> change for a sublayer in my UIView (on <code>tintColorDidChange</code>).</p>
  
  <p>I need to animate from the layer's current background colour to the new tint colour several times (different tint colours each time), so the model value for backgroundColor needs to be updated (I can't use <code>removedOnCompletion = false</code> on the animation).</p>
  
  <p>Using CABasicAnimation I have the colour change animation working fine if I don't update the model value (but of course the colour resets after the animation is complete).
  When I try to update the model value the colour change happens immediately and the animation is lost.</p>
  
  <p>I attempted to disable the implicit animation and update the model value with <code>CATransation</code> but the animation is still lost.</p>
  
  <p>How can I update the <code>backgroundColor</code> model value and keep my fade animation working?</p>
  
  <pre><code>override func tintColorDidChange() {
      super.tintColorDidChange()
  
      let colourAnim = CABasicAnimation(keyPath: "backgroundColor")
      colourAnim.toValue = self.tintColor.CGColor
      colourAnim.duration = 1.0
      self.spinnerLayer?.addAnimation(colourAnim, forKey: "colourAnimation")
  
      CATransaction.begin()
      CATransaction.setDisableActions(true)
      self.spinnerLayer?.backgroundColor = self.tintColor.CGColor
      CATransaction.commit()
  }
  </code></pre>