Is there an way to pause an Core Animation and resume it at some time later?

微笑、不失礼 提交于 2019-12-03 08:02:37
Douglas

You can pause layer animations by setting the speed of the animation to zero, see How to pause the animation of a layer tree.

Dermot

To anyone who comes searching, this is how you pause and resume animations:

https://developer.apple.com/library/archive/qa/qa1673/_index.html

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"]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!