简体   繁体   English

UINavigationBar黑色,但statusBar保持黑色

[英]Black UINavigationBar but statusBar stays black

I want to go from a black statusbar to a white statusbar. 我想从黑色状态栏转到白色状态栏。

This is my vc structure: A -> nav controller -> B 这是我的vc结构: A -> nav controller -> B

Somehow I can't seem to set it to white, whatever I try. 无论如何,我似乎都无法将其设置为白色。 I tried the simplest solution of setting the navigationController's style to black, but that won't work either!! 我尝试了将navigationController的样式设置为黑色的最简单的解决方案,但是那也不起作用! I'm stuck on this for hours, and I've even tried to a custom extension on UINavigationController but somehow the statusbar seems really unresponsive. 我坚持了几个小时,甚至尝试在UINavigationController上自定义扩展,但状态栏似乎真的没有响应。 For reference, this is my nav/statusbar like: 供参考,这是我的导航/状态栏,例如:

在此处输入图片说明

This is my setup in VC B: 这是我在VC B中的设置:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent; 
[self preferredStatusBarStyle];

Am I missing something big? 我错过了什么大事吗? How can the statusbar be black when the navbar is black too? 导航栏也为黑色时,状态栏如何为黑色?

Open the "info.plist" file. 打开“ info.plist”文件。 Add a new item with "Status bar style" as the key and "Opaque black style" as the value. 添加一个新项目,其状态键为“状态栏样式”,值为“不透明黑色样式”。

This should solve your problem 这应该可以解决您的问题

2nd Solution: 第二解决方案:

 [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];

You can see different statusBarStyle in the above function. 您可以在上面的函数中看到不同的statusBarStyle。 Call this in your viewController 在您的viewController中调用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM