CALayer drawing in the background

I need to make a large and complex drawing in an iOS application. The drawing area should also be scrollable and scalable. I implemented this by dividing the drawing area into many small CALayers like tiles. Whenever the user scrolls the drawing area by some amount, the tiles from the invisible area move to the other side, and the new content is displayed inside. Each CALayer has a drawing delegate, and only moved fragments receive a call to setNeedsDisplay.

In fact, I somehow mimic the behavior of CATiledLayer, which I cannot use directly, because I need more control and flexibility than this provides.

My code is still working, but there are still hickups in complex graphics in the user interface, and the content is redrawn while scrolling. I was hoping that the drawing would be completely in the background, but the UI thread seems to be blocked while drawing.

Is there a way to get iOS to draw a CALayer delegate asynchronously in the background? I really do not mind if the drawing is delayed a little (since the tile will appear outside the visible area in any case).

+6
source share
1 answer

Set the drawsAsynchronously property to YES . This will trigger draw requests in the background thread instead of drawing in the main thread.

+6
source

All Articles