This works great. The content of layer 1 appears overdrawn by the content of layer 2 and then layer 3 overwrites the first two layers. All of the drawing is done using calls like:

CGContextAddArc(context,cx,cy,radius,-fromDir,toDir,1-curve);

For performance reasons I replaced a lot of the repetitive drawing commands like the above with images so that the results should be the same, but instead of drawing CGContextAddArc() 20 times I tell the image to draw itself 20 times:

[myArcImage drawAtPoint: loc];

With that one change, however, the order of overlay seems to have changed. The images do get drawn to the collective view eventually, but only those portions of the images that do not overlay other lines and arcs drawn to the other contexts. I've played with using blending in the drawAtPoint variant, but that only affects the portions of the image that are visible.

Any ideas on why lines and arcs overlay content in other layers but images do not?

1 Answer
1

OK, it dawned on me what I was doing. The arcs and lines I was drawing were similar to the CGContextAddArc() call above and that call takes as a parameter the context on which to draw. When I switched over to drawing images, the drawAtPoint() method does not take a context as an argument. Instead it draws the image to the current context, which in my case was the context for the current UIView.

The solution to my problem is to wrap the drawAtPoint call with a push/pop context call: