1

我的 AppDelegate 中有一个 UINavigationController 和一个具有 UITableView 的 RootViewController。启动时,状态栏将其颜色更改为导航栏的颜色。当我将导航栏涂成橙色时,状态栏是这样的:

enter image description here

我的导航栏似乎移到了顶部。导航控制器似乎无法识别状态栏。我该如何解决这个问题?

我的应用程序中只有一个 AppDelegate 和一个空的 RootViewController。我application:didFinishLaunchingWithOptions的是:

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;

我的 RootViewController IB 文件只有一个空视图。

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

4

3 回答 3

6

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];
于 2013-03-29T22:59:05.560 回答
4

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

于 2013-03-29T22:51:55.753 回答
2

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.

于 2013-06-18T23:01:37.117 回答