tags:

views:

34

answers:

1

I am working through the iPhone_3 Development book by Dave Mark and I have a quick question arising from chapter_6 with regards to the way the UIToolbar is placed over the underlying view.

In the example in the book there are 2 controllers with associated views (blueView & yellowView) and a 3rd switchController (UISwitchController). Both the "yellow" & "blue" views are placed behind the view controllers view using atIndex:0 The only object on the view controllers view is a UIToolbar.

My question is how does the view controllers view know to make the area above the UIToolbar transparent so that you can see through to the "yellow" or "blue" views, whilst at the same time keeping the toolbar from that view visible?

Does that make any sense,

gary

+2  A: 

Well, the view are inserted as subviews inside of of SwitchViewController.view, so they will always appear above the SwitchViewControllers view. The other view is removed, e.g. in

[yellowViewController.view removeFromSuperview];
[self.view insertSubview:blueViewController.view atIndex:0];

Keep in mind that a view appears behind its subview by default, and insertSubview:atIndex: can't place it behind the view itself, as a view is not contained in the list of its own subviews.

MrMage
Dang it, beat my post by five seconds!
TechZen
Thank you, your answer did take me down the right path. What I was missing was that my background color for MainWindow.xib was white, changing it to the color of my controller.xib removed the anoying edge. Much appreciated.
fuzzygoat
So this answered http://stackoverflow.com/questions/2156795/white-edge-when-orienting-dark-colored-view, too?
MrMage