1
votes

I have a UINavigationController in my AppDelegate with a RootViewController that has a UITableView. On startup, the status bar changes its color to the color of the navigation bar. When I colored my navigation bar to orange, this is what the status bar is looking like:

enter image description here

It seems that my navigation bar is shifted to the top a little bit. It appears that the navigation controller does not recognize the status bar. How can I fix this issue?

The only thing I have in my app is an AppDelegate and an empty RootViewController. My application:didFinishLaunchingWithOptions is:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[navigationController.navigationBar setTintColor:[UIColor orangeColor]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;

My IB file for RootViewController just has an empty view.

Nothing unusual. I'm pretty experienced with iOS and that's how I've been doing it every single time. I have no idea what is different this time.

Could someone please advise me? Thanks

3
What makes you say that your navigation bar was shifted in any way? From the screenshot you have posted, things look just fine.Till

3 Answers

6
votes

Set your status-bar-style towards UIStatusBarStyleBlackOpaque and you should get a solid black bar.

To do that, use setStatusBarStyle:animated: on your applications' instance:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque 
                                            animated:NO];
4
votes

In iOS 6.0 the status bar changes color to match the navigation bar, if there is one. This is expected behavior.

2
votes

Add this code:

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

This will make your status bar black again.

You should add it after changing the color of your navigation bar.