CALayer drawInContext vs addSublayer

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2009-08-01T03:09:57Z Indexed on 2010/05/15 12:04 UTC
Read the original article Hit count: 496

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about calayer