Status bar tint color changes to black in iOS 6
Asked Answered
L

3

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.

Larch answered 18/10, 2012 at 23:22 Comment(0)
R
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!

Recalesce answered 23/1, 2013 at 17:54 Comment(4)
Thanks, this works if the status bar style is set like so: application.statusBarStyle = UIStatusBarStyleBlackTranslucent.Larch
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!Linkwork
This does not work for me building against the iOS 6.1 SDK. Can anyone confirm that this is the case?Packton
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.Beriberi
Y
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://mcmap.net/q/590058/-set-status-bar-tint-colour.

Yettayetti answered 30/1, 2013 at 20:37 Comment(0)
F
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]];
Funk answered 18/10, 2012 at 23:44 Comment(1)
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.Larch

© 2022 - 2024 — McMap. All rights reserved.