ioscocoaios7ios7-statusbar

iOS7 Navigation Bar + Status Bar Text Color


I have problems with colour of text in Status Bar. I want to make colour of text white, but keep black colour on modal views.

I have next configuration:

Background colour of UINavigationBar set to dark via appearance.

View controller-based status bar appearance set to YES

My subclass of UITabBarViewController has next methods:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNeedsStatusBarAppearanceUpdate];
}

These methods are called after application started.

I also have same methods calls in my UIViewControllers subclasses:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent; // This method never called
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNeedsStatusBarAppearanceUpdate];
}

I also tried to change return value of -preferredStatusBarStyle to UIStatusBarStyleDefault (well, I know that it should paint text in black, but I tried anyway)

Same thing for setting Status Bar option to Light Content in Storyboard. Doesn't work too.

I know there are a lot of questions on SO similar to mine, but proposed solutions doesn't help in my situation.

My status bar still looks like this:

StatusBar

And I want to change its colour to white =/


Solution

  • This is a work around that I occasionally found right now after struggling with this issue for about 2 weeks.

    // This is a workaround just enables white text colour in status bar in iOS7, iOS7.1
    // Dont touch it until things break
    // Despite this category says "draw white", colour automatically becomes black on white background w/o additional code
    @interface UINavigationController (StatusBarStyle)
    
    @end
    
    @implementation UINavigationController (StatusBarStyle)
    - (UIStatusBarStyle)preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    @end
    // Place at the bottom of your AppDelegate.m
    // Magic!
    

    I need to thank people who answered this question, but I already tried these solutions and they didn't help :( This category on UINavigationController just works.