Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent CALayer from implicit animations?

Tags:

iphone

calayer

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?

like image 361
openfrog Avatar asked Oct 07 '10 17:10

openfrog


1 Answers

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

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
//change background colour
[CATransaction commit];
like image 79
Ben Avatar answered Sep 21 '22 18:09

Ben