How to prevent CALayer from implicit animations?

openfrog picture openfrog · Oct 7, 2010 · Viewed 7.8k times · Source

When I set the backgroundColor property of an CALayer instance, the change seems to be slightly animated. But I don't want that in my case. How can I set the backgroundColor without animation?

Answer

Ben picture Ben · Oct 7, 2010

You can wrap the change in a CATransaction with disabled animations:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
//change background colour
[CATransaction commit];