Reputation: 40329
I have a Core Animation running and want to pause it when a button is pressed. So there is a method -pauseAnimation. When the animation is paused, I want the animated view to stay in the state as it currently was while animating. i.e. if a view moves from top left to bottom right, and somewhere in the middle the animation is paused, the view should stay in the middle. Is there a way to do this?
as far as i can remember there is an setAnimationsEnabled=NO option, but that doesn't work when the animation runs, right?
Upvotes: 0
Views: 1189
Reputation: 37763
You can pause layer animations by setting the speed of the animation to zero, see How to pause the animation of a layer tree.
Upvotes: 2
Reputation: 5421
You can do this by disabling animations and then setting the model layers' values to the presentation layers' values (for all properties that define your animation).
eg. layer.transform = layer.presentationLayer.transform;
Resuming the animation = re-enable animations and animate from current positions to the desired final positions (you might have to adjust curves, etc to get something acceptable).
Upvotes: 1