更改 CALayer 属性的动画时间
我有一个 CALayer 来动画显示其图像内容的变化。现在,我如何更改该动画发生所需的时间?
I have a CALayer to animate a change in its image contents. Now, how can I change how long it takes for this animation to take place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您只需调用:
在 -layoutSublayers 中或您修改图层并期望它们隐式动画的任何其他地方。这将影响当前的隐式事务以及该事务中的任何子事务。
You can just call:
in -layoutSublayers or anywhere else that you modify the layers and expect them to implicitly animate. This will effect the current implicit transaction and any sub-transactions within this one.
另一种方法是:
该代码将在 2.5 秒内以动画方式显示 CALayer 内容的变化。您还可以使用它来完全禁用所有动画。像这样:
A different way to do this:
That code would animate the change of the CALayer's contents over 2.5 seconds. You can also use this to disable all animations completely. Like this:
这或多或少很简单。您有一个 ivar
CALayer *yourLayer
。然后设置委托并实现委托方法-(id)actionForLayer:forKey:
It's more or less simple. You have an ivar
CALayer *yourLayer
. Then you set the delegate and implement the delegate method-(id<CAAction>)actionForLayer:forKey: