CABasicAnimation with zero duration

1.4k views Asked by At

I have a CALayer in an AVMutableComposition that is faded in, should stay on screen for a while and then disappear. The problem is, it should disappear without an animation, but CABasicAnimation has a minimum duration of 0.25 seconds.

How would can I achieve to set the opacity of the layer after a given time without animating it?

1

There are 1 answers

0
clemens On

Encapsulating the removal of the layer into a Core Animation transaction where you disable animations:

[CATransaction begin];
[CATransaction setDisableActions:YES];
// remove the layer from its hierarchy
[CATransaction commit];

or the same in Swift:

CATransaction.begin()
CATransaction.setDisableActions(true)
// remove the layer from its hierarchy
CATransaction.commit()