Search code examples
objective-ccore-animationcalayer

Add a sublayer to a CALayer without animation?


How can I add a sublayer to a CALayer without animation? Usually when you add one it "fades in" and when you remove one it "fades out".

How to supress the animation?


Solution

  • Have you tried this:

    [CATransaction begin];
    [CATransaction setValue:(id)kCFBooleanTrue
                     forKey:kCATransactionDisableActions];
    [layer addSublayer:sublayer];
    [CATransaction commit];
    

    from the Apple docs?