tags:

views:

49

answers:

1

Hi,

I'm drawing an image... but my problem is that if there's another imageview in the view, my drawn image (green circle) is not visible, seems it's a lower layer than the imageView.

First, what I've do is that I subclass UIView, MyDrawView, in this is class I do the drawing functionality. Then, I set in IB the view to be MyDrawView.

Here's my sample code: http://snipplr.com/view/37149/draw-image/

Can you advise me how to fix this problem?

Thanks

A: 

Subviews are in front of the view that contain them. So you could use the background view as "main view" for your view controller, and add your custom view as a subview to it.

Make sure that you call the correct init method on your custom view class, so that the image actually gets initialized.

Eiko
Thanks for the reply... I didn't get what you meant..sorry, still a newbie..How can you translate it in code? or you can give some guide?Anyway, I've already subclass UIView, that is MyDrawView.. Then, i've set in IB that the view of the app will be MyDrawView
devb0yax
That's a good way to do it in general, *but* you add another view (UIImageView) on top of it in your view controller's viewDidLoad: method. And *on top of* means just that. It covers the view itself. If you want your own view to be in front of the background image, you need to do it the other way around - that is adding your own view as a subview to the background UIImageView. You can do that in code, or in IB, maybe you want to add a view to your nib that contains both the background and the content view.
Eiko