Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Controller Transparent Bar Style is not working

I am using a navigation controller, and I have the style set to :

navController.navigationBar.barStyle = UIBarStyleBlackTranslucent;

But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left or right, all my view, the current one, shifts to the top exactly the size of the navigation bar. And it is there where I can see my background through the navigation controller bar. Any ideas? When my barStyle is set to opaque, everything looks fine. I was thinking on setting my view frame a negative 'y' value, but I think there should a more elegant way.

like image 697
carlos Avatar asked Oct 23 '08 02:10

carlos


People also ask

How do I make my navigation bar translucent?

Creating a transparent navbar is very easy - just don't add a color class . bg-* to the navbar. In this case, the Navbar will take the color of the parent's background color.

How do I change the appearance of my navigation bar?

To change the appearance of the navigation bar: Choose “standard” and “scroll edge appearances” for the navigation bar, by setting the appearance proxy of UINavigationBar : “Standard”, and “ScrollEdge” appearances. Open the project's storyboard file. Select the UINavigationBar from your UINavigationController scene.

How do I change the navigation bar on my Iphone?

Change the Bar Style A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.


1 Answers

I believe the UINavigationController assumes that your controller view frames don't include the area beneath the navigation bar.

UIBarStyleBlackTranslucent is more often used for UIToolbar, so Apple probably didn't make it easy to use it nicely with UINavigationBar. You'll probably need to abandon the UINavigationController, or start hacking the frames (careful with rotations), if you want to reliably render under the bar area.

Also, if your intention is to hide the navigation bar after a few seconds, you'll have a much easier time if you make it fade out (like the Photos app) instead of trying to slide it up (like Mobile Safari). Trust me on that one... that took me a lot of time to learn the hard way.

like image 166
Marco Avatar answered Oct 20 '22 17:10

Marco