Search code examples
iphoneobjective-cioscore-animationcore-graphics

Improving performance of Core Animation


I have built a UI where the majority of what's on screen is put there using CALayer's. The layers are fairly simple in terms of their setup; the majority have an image set as their contents and a couple have a shadow. There are also some CALayer derivatives such as CATextLayer and CAGradientLayer. At any one time there is about 18 layers on screen. The contents of 11 layers change frequently (but not to represent an animation), and the same 11 can be scrolled to the left or the right as they are embedded in a UIScrollView.

I have noticed that performance is a little sluggish on both my 3GS and 4 so I am looking for ways to tune what I have to hopefully improve performance somewhat.

I have set rasterizationScale to the appropriate scale depending on the device and have set shouldRasterize to YES.

The images are passed to the layers in the following way ...

someLayer.contents = (id)someUIImage.CGImage

Is there anything else I can do to improved the overall performance?


Solution

  • The best thing to do would be to use the profiling tools available to you to figure out exactly what is slowing you down.

    This previous answer says it better than I could: iOS / Core-Animation: Performance tuning