Search code examples
iosobjective-cuistatusbar

Objective-C/Xcode Status Bar Color same as Nav Bar Color


I am trying to make my status bar the same color as my navigation bar, and not the same color as my background. I haven't found any solutions that work with iOS 12 Objective-C and aren't going to get my app banned from the app store.

This is how I'm setting up the Nav Bar:

[navController setBarTintColor:[UIColor colorWithRed:0.26 green:0.53 blue:0.96 alpha:1.0]];
[navController setTranslucent:FALSE];
[navController setBarStyle:UIBarStyleBlack];
[navController setTintColor:[UIColor whiteColor]];

And I've tried View controller-based status bar appearance as both YES and NO, neither making a difference.

EDIT: The current behavior: status bar is the same color as the view's background. I'm trying to have it the same color as the navigation bar background.

enter image description here

I changed the background to red to show what I'm talking about. In this case, I'd like to make the status bar (or anything above the nav bar) blue, the same color as the nav bar.


Solution

  • In iOS 12 the status bar has no color. It has white or black text and its background is clear (transparent).

    If the navigation bar is correctly configured, it appears behind the status bar and so they are the same apparent color. But your navigation bar (or whatever the "Available Jobs" thing is) is not correctly configured; its top stops too early (too low), so your red view is visible behind it.

    What you see should look more like this:

    enter image description here

    That is a table view in a navigation controller in a tab view controller. So what you have must be some other arrangement, but you have not explained what it is.

    For example if you have a “loose” navigation bar follow my instructions here: https://stackoverflow.com/a/30831452/341994. That is for a toolbar but it works the same way.

    But using a navigation controller is easier and better even if you will never do any navigation!