CAKeyframeAnimation rotationMode resets angle to 0 when done.

I have a keyframe animation that animates an indicator in a control. Picture something like a speedometer in an arc where a pointer animates along the top.

I set rotationMode on the animation to kCAAnimationRotateAuto and the animation itself works perfectly. When the animation completes, the pointer blinks back to a zero angle rotation. I want it to stay in the rotation it was in at the end of the animation.

I tried using animationDidStop:finished: to set my layer's transform to the desired angle with layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1) at the end of the animation which does set the correct rotation angle at the end of the animation, but then the animation itself has an incorrect rotation.

I tried setting the layer's transform before the animation starts thinking the animation would animate to that value, but the animation was even more bonkers.

Not sure what else to try. The rotationMode works beautifully, except for the end state.

I changed the implementation to use a CADisplayLInk and set the values myself.

CAKeyframeAnimation rotationMode resets angle to 0 when done.
 
 
Q