Search code examples
iphonecalayer

How to prevent CALayer from implicit animations?


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?


Solution

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

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