views:

53

answers:

2

I have a subclass of UIView in which I've added some subviews to in my initWithFrame method. I've added a background, amongst other things.

I want to draw some shapes on top of these views (which happen to cover the entire screen). But, when I implement drawRect: to draw these shapes, they didn't show up. Upon removing the other subviews, I realized that the shapes were begin drawn "under" the other subviews.

How can I draw them on top?

+1  A: 

Maybe, you should add transparent view on top of others and draw shapes on it?

kpower
Thanks for that -- I ended up creating another subclass of UIView, set its `backgroundColor = [UIColor clearColor]`, and then drawing with `drawRect:` in the new subclass. Thanks for the idea!
Calvin L
+1  A: 

Call [super drawRect:rect] at the beginning of the drawRect: for the owning view. This will draw all the subviews into the current context. Additional drawing you do for the owning view should then go on top.

Rob Napier