持续时间为零的CABasicAnimation

Swi*_*ude 7 calayer cabasicanimation avmutablecomposition

我有一个CALayer在AVMutableComposition被褪,应该在屏幕上停留了一会儿,然后消失.问题是,它应该在没有动画的情况下消失,但CABasicAnimation最小持续时间为0.25秒.

如何在没有动画的情况下在给定时间后设置图层的不透明度?

cle*_*ens 4

将层的删除封装到核心动画事务中,您可以在其中禁用动画:

[CATransaction begin];
[CATransaction setDisableActions:YES];
// remove the layer from its hierarchy
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)

或在 Swift 中相同:

CATransaction.begin()
CATransaction.setDisableActions(true)
// remove the layer from its hierarchy
CATransaction.commit()
Run Code Online (Sandbox Code Playgroud)