5

I am apparently not understanding how to use the status bar tint in iOS 6. I have read this question: Change statusbar tint colour but implementing the solutions suggested there has not resolved the issue.

I have configured the settings in the target summary pane (default for style and tinting) and added the status bar tint parameters dictionary to my info.plist as described in WWDC 2012 Advanced Appearance Customization.

My status bar tints correctly at launch but once I navigate to another view controller the status bar changes to black.

The second view controller is embedded in its own navigation controller. Could this be the root of the issue?

Whatever the cause, I am hoping that someone can offer a solution that will allow me to make my status bar be tinted consistently throughout my application.

Please let me know if anything needs clarification and thanks in advance for any assistance.

Community
  • 1
  • 1
geraldWilliam
  • 4,123
  • 1
  • 23
  • 35

3 Answers3

13

Today I ran into the same issue, but none of the sugested answers would help me.

Since I defined my own color (red, blue, green, alpha), I did not want to add a UIStatusBar via IB, I need a one-line-solution.

After testing for a while the following worked for me:

  1. In the Project Summary select Status Bar Style Black Transculent from the drop down menu.
  2. In application: didFinishLaunchingWithOptions: enter the following line of code:

    self.window.backgroundColor = [UIColor redColor]; //example color

Somehow this would not work for me when setting the style via code in application: didFinishLaunchingWithOptions:

Enjoy!

pmk
  • 1,897
  • 2
  • 21
  • 34
  • 1
    Thanks, this works if the status bar style is set like so: application.statusBarStyle = UIStatusBarStyleBlackTranslucent. – geraldWilliam Jan 23 '13 at 19:44
  • Thank you so much! i was already afraid that i had to use the uinavigationbar method which would really mess up my project since i am using multiple navigationbars and switching between them caused the statusbar color to disappear. This worked great! – fellowworldcitizen Apr 11 '13 at 10:08
  • 1
    This does not work for me building against the iOS 6.1 SDK. Can anyone confirm that this is the case? – huesforalice Aug 21 '13 at 10:30
  • It is working for me if I add `[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;` `self.window.backgroundColor = [UIColor redColor];` to `AppDelegate`, but only on iPhone. On iPad it seems that `blackTranslucent` doesn't work. – Levi Sep 09 '13 at 05:10
1

One solution is to put an invisible navigation bar in front of your interface. You might have to subclass UINavigationController if you're in a navigation interface already. For example:

UINavigationBar* nav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0,320,1)];
nav.tintColor = [UIColor redColor];
nav.alpha = 0;
[self.navigationBar.superview addSubview:nav];

This causes the status bar to be red, regardless of the tint or background color of the navigation bar. This works also if there is no navigation bar.

Credit where credit is due; I got the idea of setting alpha to 0 from https://stackoverflow.com/a/13587525/341994.

Community
  • 1
  • 1
matt
  • 515,959
  • 87
  • 875
  • 1,141
0

The second view controller is embedded in its own navigation controller. Could this be the root of the issue?

This is most likely the issue - but I also would have thought the plist entry would make it global. Have you tried setting it programatically using UIAppearance (assuming you only support ios6+)?

[[UITabBar appearance] setTintColor:[UIColor redColor]];
Edwin Iskandar
  • 4,119
  • 1
  • 23
  • 24
  • If I'm not mistaken, the status bar in iOS 6 derives its tint from UINavigationBar, not UITabBar. I have set the appearance of the navigation bar using the appearance protocol (which is available in iOS 5+, actually). And the custom image of the navigation bar appears as expected throughout the application. The status bar, however, fails to take its tint from the navigation bar after the initial navigation controller has been removed from the view. Even after navigating back to it, the status bar remains black. – geraldWilliam Oct 18 '12 at 23:53