如何禁用 CALayer 隐式动画? [英] How to disable CALayer implicit animations?
本文介绍了如何禁用 CALayer 隐式动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
快把我逼疯了!我正在开发绘图应用程序.假设我正在处理一个名为 sheet 的 UIView
.
It's driving me crazy! I am working on a drawing application. Let's say I am working on a UIView
called sheet.
我正在向该视图添加一些子图层([sheet.layer addSublayer:...]
),然后我想绘制到它们中.为此,我创建了一个 CGImageRef
并将其放入图层的 contents
.但它是动画的,我不想要那样.
I am adding some sublayers to this view ([sheet.layer addSublayer:...]
) and then I want to draw into them. To do so I am creating a CGImageRef
and putting it into the layer's contents
. But it's animated and I don't want that.
我什么都试过了:
removeAnimationForKey:
removeAllAnimations
- 设置动作字典
- 使用动作层
delegate
[CATransaction setDisableAnimations:YES]
似乎是对的.我不明白为什么这个图层仍然是动画的;_;
难道我做错了什么?有什么秘诀吗?
It's seems correct. I don't understand why this layer is still animated ;_;
Am I doing something wrong? Is there a secret way?
推荐答案
Swift
CATransaction.begin()
CATransaction.setDisableActions(true)
// change layer properties that you don't want to animate
CATransaction.commit()
这篇关于如何禁用 CALayer 隐式动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文