I have several Core Animation's going on at the same time. They all have an context and an animation id, where the context is the object that's beeing animated (UIImageView objects). I would like to pause them, so that the animation just stops temporarily, and then when some things are done, resume it to complete it. These things happen only on very fast scroll movements in an UIScrollView. I want to improve performance by stopping all ongoing animations but not the one that makes the scroll view scroll. I have implemented an custom animation of the contentOffset for that scroll view.
views:
705answers:
2
+2
A:
The only way I have gotten around this is the following.
For each view you wish to stop animating:
Set the view's frame to the presentation layer
Remove all animations from that view
Perform your scroll
Recalculate animations
Add new animations to the view
I know it isn't what you want to hear, but it isn't as bad as it sounds. A good way to track the views you want to stop is to give them a predetermined tag.
To remove animations:
[myView.layer removeAllAnimations]
[myView.layer removeAnimationForKey:@"theAnimationKey"]
Corey Floyd
2009-05-30 18:53:50
How would you remove animations from the view?
Thanks
2009-05-30 19:29:44
[myView.layer removeAllAnimations] or [myView.layer removeAnimationForKey:@"theAnimationKey"]
Corey Floyd
2009-05-30 20:06:02
This might be a stupid question, but how do I set the view's frame to the presentation layer? I'm assuming you're not talking about the frame property of the view here.
Kare Morstol
2009-09-09 21:53:20
If you need to set the view's frame to the presentation layer, then you just say view.frame = view.layer.presentationLayer.frame
Corey Floyd
2009-09-10 06:25:02
A:
You can pause layer animations by setting the speed of the animation to zero, see How to pause the animation of a layer tree.
Douglas
2010-08-15 18:20:45