iOS状态栏更改颜色以单独匹配导航栏 [英] iOS Status Bar changing color to match navigation bar on its own

查看:386
本文介绍了iOS状态栏更改颜色以单独匹配导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UINavigationController在我的AppDelegate与一个RootViewController有一个UITableView。在启动时,状态栏将其颜色更改为导航栏的颜色。当我将导航栏的颜色设置为橙色时,状态栏的外观如下:

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:

看来我的导航栏被移到顶部了一点。看来导航控制器无法识别状态栏。我如何解决这个问题?

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?

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

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;

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

My IB file for RootViewController just has an empty view.

没什么不寻常的。我有iOS的经验,这是我一直在做的每一次。我不知道这次有什么不同。

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

推荐答案

将您的状态栏样式设为 UIStatusBarStyleBlackOpaque

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

要做到这一点,在应用程序的实例上使用 setStatusBarStyle:animated:

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

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

这篇关于iOS状态栏更改颜色以单独匹配导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆