0

Possible Duplicate:
iPhone SDK - make UINavigationBar transparent

In my app I'm using a NavigationController that wraps all of the other views through Push Segues. So I'm wondering how I can go about setting the controller to have a clear background for all views.

I tried

[self.navigationController.navigationBar setBackgroundColor:[UIColor clearColor]];

but my view still loaded with the same stock color bar.

Anyone out there that can give me some help is greatly appreciated.

Community
  • 1
  • 1
Justin Cabral
  • 565
  • 1
  • 6
  • 20

3 Answers3

2

Like codingNinja said , you shuold inherit the UINavigationBar and override the - (void)drawRect:(CGRect)rect , in this method , you can use

[[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.0] set];
UIRectFill(rect);

to set the background color clear.

And then you can user YourNavigationBar as the navigationBar.

Guo Luchuan
  • 4,729
  • 25
  • 33
0

You aren't setting the background color of the bar but the tintColor but I don't know if you are able to make it clear.

rooster117
  • 5,502
  • 1
  • 21
  • 19
0

If you are referring to the navigation bar that comes with the viewControllers being a part of the navigationController's array of viewControllers, then you cannot simply set it that way. If you want to have clear navigation bars, the best way to do it would be to use just viewControllers without the navigation controller and present the viewControllers with modal segues. How ever you will need to handle the navigation on your own, like going from one view controller to the previous, dismissing the viewController etc.

You could subclass the navigation bar and override the drawrect method. I would personally avoid using [UIColor clearColor] as much as possible to avoid blended layers and to improve performance.

codingNinja
  • 371
  • 2
  • 18
  • I had done an app before where I did what you suggest with managing all the navigation myself. I'm going to try and subclass the nav bar and override the drawrect and then see what happens. Thanks for the explintation – Justin Cabral Jan 17 '13 at 01:49