CABasicAnimation Value Interpolation

Apple's doc is wrong:

  • fromValue is non-nil. Interpolates between fromValue and the current presentation value of the property. ❌
  • toValue is non-nil. Interpolates between the current value of keyPath in the target layer’s presentation layer and toValue. ❌
  • byValue is non-nil. Interpolates between the current value of keyPath in the target layer’s presentation layer and that value plus byValue. ❌
  • All properties are nil. Interpolates between the previous value of keyPath in the target layer’s presentation layer and the current value of keyPath in the target layer’s presentation layer. ❌

Correction:

  • fromValue is non-nil. Interpolates between fromValue and the current model value of the property. ✅
  • toValue is non-nil. Interpolates between the current model value of the property and toValue. ✅
  • byValue is non-nil. Interpolates between the current model value of the property and that value plus byValue. ✅
  • All properties are nil. Interpolates between the previous presentation value and the current model value of the property. ✅

Notice:

  • Current model value is used by Core Animation present-progressively, i.e., if you change the model value while the animation is still on the fly the animation changes its curve to use the interpolation between the new model value and the other fixed value. It is reference-captured, like __block variable in a block.
  • Previous presentation value is value-captured and the same value is used throughout the animation by Core Animation.