如何暂停当前正在运行的动画? [英] How can I pause a currently running animation?

查看:133
本文介绍了如何暂停当前正在运行的动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Core Animation,并且想在按下按钮时将其暂停。因此,有一个方法-pauseAnimation。动画暂停时,我希望动画视图保持动画时的当前状态。即,如果某个视图从左上角移动到右下角,并且在中间某个位置暂停了动画,则该视图应停留在中间位置。
有没有办法做到这一点?

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?

据我记得有一个setAnimationsEnabled = NO选项,但是在动画播放时不起作用

as far as i can remember there is an setAnimationsEnabled=NO option, but that doesn't work when the animation runs, right?

推荐答案

您可以通过将动画速度设置为零来暂停图层动画,请参见如何暂停图层树的动画

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

这篇关于如何暂停当前正在运行的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆