1
113
我的方法是创建一个新的动画到你的终点。设置非常短的持续时间,并确保使用
|
2
350
用途:
|
3
62
最简单的停止方法 全部的 特定视图上的动画, 立即 是这样的: 将项目链接到quartzcore.framework。在代码开头:
现在,当你想停止一个视图上所有动画的轨迹时,请这样说:
中间一行本身就可以工作,但是会有一个延迟,直到runloop完成(“重绘时刻”)。要防止这种延迟,请将命令包装在显式事务块中,如图所示。如果当前运行循环中没有对该层执行其他更改,则可以执行此操作。 |
4
45
在iOS 4及更高版本上,
使用
例如,假设您有一个带有活动指示器的视图。您希望在一些可能耗时的活动开始时淡入活动指示器,并在活动结束时淡出。在下面的代码中,带有活动指示器的视图被调用
|
5
40
要取消动画,只需在uiview动画之外设置当前正在动画的属性。这将使动画停止在任何位置,并且uiview将跳转到刚才定义的设置。 |
6
16
很抱歉恢复了这个答案,但在iOS中,10件事情发生了变化,现在可以取消了,您甚至可以优雅地取消! iOS 10之后,您可以使用 UIViewPropertyAnimator !
如果通过“真”,它将取消动画,并在取消动画的位置停止。不会调用完成方法。但是,如果传递“假”,则负责完成动画:
您可以完成动画并保持当前状态(.current),或转到初始状态(.start)或结束状态(.end)。 顺便说一下,您甚至可以稍后暂停和重新启动…
注意:如果您不想突然取消,可以在暂停动画后反转动画,甚至更改动画! |
7
9
如果要通过更改常量而不是视图属性来设置约束的动画,则其他任何方法都不适用于iOS 8。 示例动画:
解决方案: 您需要从受约束更改及其子图层影响的任何视图的图层中删除动画。
|
8
8
|
9
5
以上都没有为我解决,但这有助于:
我解决了我的问题,“我想从你出现的地方动画”(“你”是指视图)。如果你想要,那么:
将位置设置为表示层
我使用一些选项,包括
但是由于苹果的文档是模糊的,我不知道它在使用时是否真的覆盖了其他动画,或者只是重置计时器。
现在这应该是一个不错的解决方案。 |
10
5
|
11
1
我也有同样的问题;API没有任何东西可以取消某些特定的动画。这个
禁用所有动画,因此不适用于我。有两种解决方案: 1)使动画对象成为子视图。然后,如果要取消该视图的动画,请删除该视图或将其隐藏。非常简单,但如果需要保持子视图在视图中,则需要重新创建不带动画的子视图。 2)只重复一个anim,并在需要时使代理选择器重新启动anim,如下所示:
2)的问题是,当动画完成当前动画循环时,始终存在延迟停止动画。 希望这有帮助。 |
12
1
斯蒂芬·达林顿解决方案的快速版本
|
13
0
即使按上述动画方式取消动画
|
14
0
|
15
0
暂停动画而不将状态恢复为原始或最终状态:
|
16
0
当我和
|
yelabd · 沿贝塞尔路径的一部分设置UIView动画 6 年前 |
Henry Cooper · 为什么核心动画类型采用字符串关键点路径? 6 年前 |
fearmint · CAEmitterLayer多单元交错 7 年前 |
gvalmon · 围绕中心旋转NSView 9 年前 |