Alex Rivera | Logout

Navigation Controller Transparent Bar Style is not working

Asked 2008-10-23T02:15:17.610
10

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.

Edit
Report

1 Answer

7

Simply use a transparent background image, and translucent = YES to allow the content to flow below the bar. Works on iOS 5 / 6. Add in viewDidLoad.

self.navigationController.navigationBar.translucent = YES;
UIImage * backgroundImage = [UIImage imageNamed:@"spacer.gif"];
[self.navigationController.navigationBar setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:UIBarMetricsDefault];

I attached the spacer.gif image here, a single 1px x 1px transparent image.

spacer.gif

answered 2012-12-11T10:30:10.447

Your Answer