CALayer drawInContext vs addSublayer
- by Michael
How can I use both of these in the same UIView correctly?
I have one custom subclassed CALayer in which I draw a pattern within drawInContext
I have a another in which I set an overlay PNG image as the contents.
I have a third which is just a background.
How do I overlay all 3 of these items?
[self.layer addSublayer:bottomLayer]; // this line is the problem
[squaresLayer drawInContext:viewContext];
[self.layer addSublayer:imgLayer];
The other 2 by themselves draw correctly if I do them in that order. No matter where I try and put bottomLayer, it always prevents squaresLayer from drawing. The reason I need 3 layers is I intend to animate the colors in the background and custom layers. The top layer is just a graphical overlay.