为了账号安全,请及时绑定邮箱和手机立即绑定

取消UIView动画?

取消UIView动画?

九州编程 2019-08-06 14:03:12
取消UIView动画?是否可以在UIView动画进行过程中取消动画?或者我是否必须降至CA级别?即我已经完成了这样的事情(也可能设置一个结束动画动作):[UIView beginAnimations:nil context:NULL];[UIView setAnimationDuration:duration];[UIView setAnimationCurve: UIViewAnimationCurveLinear];// other animation properties// set view properties[UIView commitAnimations];但是在动画完成之前我得到动画结束事件,我想取消它(剪短它)。这可能吗?谷歌搜索周围发现一些人问同样的问题没有答案 - 一两个人推测它不能完成。
查看完整描述

3 回答

?
红糖糍粑

TA贡献1815条经验 获得超6个赞


我这样做的方法是为你的终点创建一个新的动画。设置一个非常短的持续时间,并确保使用该+setAnimationBeginsFromCurrentState:方法从当前状态开始。将其设置为YES时,将缩短当前动画。看起来像这样:


[UIView beginAnimations:nil context:NULL];

[UIView setAnimationBeginsFromCurrentState:YES];

[UIView setAnimationDuration:0.1];

[UIView setAnimationCurve: UIViewAnimationCurveLinear];

// other animation properties


// set view properties


[UIView commitAnimations];


查看完整回答
反对 回复 2019-08-06
?
临摹微笑

TA贡献1982条经验 获得超2个赞

使用:


#import <QuartzCore/QuartzCore.h>


.......


[myView.layer removeAllAnimations];


查看完整回答
反对 回复 2019-08-06
?
jeck猫

TA贡献1909条经验 获得超7个赞

停止最简单的方法都在特定视图动画,立刻,是这样的:


将项目链接到QuartzCore.framework。在代码的开头:


#import <QuartzCore/QuartzCore.h>

现在,当你想停止视频中的所有动画时,请说:


[CATransaction begin];

[theView.layer removeAllAnimations];

[CATransaction commit];

中间线本身可以工作,但是在runloop完成之前有一段延迟(“重绘时刻”)。要防止该延迟,请将命令包装在显式事务块中,如图所示。这项工作在当前的runloop中没有对该层执行任何其他更改。


查看完整回答
反对 回复 2019-08-06
  • 3 回答
  • 0 关注
  • 1442 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信