Tips for optimizing performance when using tons of CALayer objects?
My app architecture / hierarchy looks like this:
UIView
UIView
CALayer | CALayer | CALayer | CALayer .... (and a few hundred more)
These CALayer instances represent small square dots in a dot matrix display for an fast countdown clock. I'm updating their backgroundColor as often per second as possible. Actually what I want is 60 times per second, but I guess the device can't do that.
I have an timer which calls an method frequently. This method then iterates over those pixel-dot layers and sets their backgroundColor to whatever is needed right now.
What optimization tips do you have to improve performance?
One thing that comes to my mind:
1) Tell every CALayer that it's opaque!
I guess there are a lot more optimization possibilities. Maybe not a flat hierarchy like I have, but a very开发者_StackOverflow社区 deep one, where every CALayer is a sublayer of another? Not sure.
Couldn’t you simply forget about the layers and render the image each frame using Quartz?
精彩评论