2008 05 21Core Animation Phantom Fade
Animating squares, this looks like that :
You're expecting layers to smoothly move to their new positions, but they're fading instead. Turns out it's because creation and animation are done in the same transaction. You're telling CA to create and animate, CA then tries to move from N objects to N+1 objects smoothly. It does that with a fade.
Do it in two transactions. Use a zero duration transaction for creating your layers, then animate them.
// Creation transaction, zero duration [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat:0] forKey:kCATransactionAnimationDuration]; [self addRect:NSMakeRect(0, 50, 90, 100)]; [CATransaction commit]; // Animation transaction, whatever duration you want [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat:duration] forKey:kCATransactionAnimationDuration]; [self animateLayers]; [CATransaction commit];
You'll then see what you expected : smooth animation to the new positions.
- CocoaNav a Cocoa Class Browser using Core Animation
- Core Animation Starfield Core Animation sample using 3D layers
- Core Animation culling problems Don't setup a projection transform on the root layer !
- Threaded Core Animation while on the main thread, update your display with
- Core Animation Bindings binding Cocoa objects to
Core Animation Bindings.zip
- Core Animation Phantom Fade seeing ghosting ? Use two transaction to create and animate your objects
- Photoshop-like compositing with Core Animation