Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CABasicAnimation with zero duration

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?

like image 888
Swissdude Avatar asked Aug 29 '13 09:08

Swissdude


1 Answers

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()
like image 184
clemens Avatar answered Oct 12 '22 06:10

clemens