I'm animating a UIView's frame property using a CAKeyframeAnimation on the view's CALayer and animating the "position" property. I'd like to be able to halt the animation at it's current state when the user taps the screen, but I'm unable to do so.
I can halt the animation easily enough by calling
[view.layer removeAnimationForKey:kFrameAnimationKey];
The problem is that neither the view's frame not it's layer's position are updated directly by the animation. If I look at the position property at the time the animation starts and when it ends in
- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)finished
it has not changed.
It seems that you need to do that explicitly when the animation stops. But if the animation stops at some arbitrary point, you don't know how far it's gone. So the question is either how to make the animation update the layer's position property as it goes, or how to know how far the animation has gone when it's been stopped.