How do i set transparency level for Navigation Bar when using NavigationController?

Discussion in 'iOS Programming' started by thedon1, Sep 22, 2013.

  1. thedon1 macrumors 6502

    Jun 26, 2010
    Hi guys, i'm using Xcode 5 and am having some trouble that Apple WWDC video hasn't fully cleared up.

    I want a semi transparent status bar. I know if i add a navigation bar, the status bar will take the same translucency and tint. This sounds good.

    I currently have a Navigation Controller which shows the Navigation Bar. My screen (UIViewController) is linked to this.

    I tick translucent in the attributes inspector for the navigation bar in the Navigation Controller.

    My connected ViewController then shows the translucent status and navigation bar as expected.

    When I go back to the Navigation Controller and change the alpha of the navigation bar, this has no impact on the connected View.

    How can I change the level of transparency when using a Navigation Controller?
  2. thedon1 thread starter macrumors 6502

    Jun 26, 2010
    OK i'm answering my own question here, I hope it's useful to others.

    It looks like you can assign a background image to the navigation bar and whatever alpha/ opacity that image has, will be picked up by the status bar.

    Create your image 640x128.

    Use this code
     [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];
    This will make the picture the background of the navigation bar and the status bar.

Share This Page