Design Element
Comment on "Core Animation Sample Code: NanoLife"
by Scott Stevenson — Feb 24
@ACoolie: Changing sphere colors or adding a lot of them takes ~15 seconds each time on my PowerMac G5

This is probably because a separate image is generated for each layer. You could change the code to only generate a single full-size image and resize the layer instead. If you do this, set kCAGravityResizeAspect for the contentsGravity property on the layer, so that the image scales with the layer.

The speed difference is nearly nonexistent for the original version of NanoLife, but it would be very noticeable for hundred/thousands of layers or if you're regenerating them frequently.
Back to "Core Animation Sample Code: NanoLife"
Design Element

Copyright © Scott Stevenson 2004-2015