简体   繁体   English

导航栏和状态栏的颜色不同

[英]Different color for navigation bar and status bar

Is it possible to have different color for navigation bar and status bar ? 导航栏和状态栏是否可以具有不同的颜色? A solution other than this will help. 以外的解决方案会有所帮助。 I am looking for some default setting. 我正在寻找一些默认设置。
What I have tried is, assigning color to navigation bar in storyboard and then for status bar I tried this accepted answer. 我尝试过的是,为情节提要中的导航栏分配颜色,然后为状态栏尝试接受的答案。
But still the status bar has the same color as navigation bar. 但是状态栏仍然具有与导航栏相同的颜色。

I've found a solution that works very well for me. 我找到了一种非常适合我的解决方案。 You can use setBackgroundImage:forBarMetrics: method which sets the background image of the nav bar and does not affect on the status bar of your app. 您可以使用setBackgroundImage:forBarMetrics:方法来设置导航栏的背景图像,并且不会影响应用程序的状态栏。 I hope this will help. 我希望这将有所帮助。

There is no way to change status bar background color from ios 7, it is always transparent. 无法从ios 7更改状态栏背景颜色,它始终是透明的。

Alternately, you can add a view with the background color you want, and add it to the top, with size as 20px. 或者,您可以添加具有所需背景色的视图,并将其添加到顶部,尺寸为20px。

Hope this help. 希望能有所帮助。

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

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