简体   繁体   English

如何在状态栏中提供文本颜色?

[英]How can I give textcolor in status bar?

Text color of the wordings in status bar cannot be changed.状态栏中文字的文字颜色无法更改。 Status Bar background color is able to change.状态栏背景颜色可以改变。 How can I change the text color in that?如何更改文本颜色?

Use -用 -

UIApplication.shared.statusBarStyle = .lightContent // Light content, for use on dark backgrounds

or或者

UIApplication.shared.statusBarStyle = .default // Dark content, for use on light backgrounds

Don't forget to edit "View controller-based status bar appearance" in info.plist and set it to NO.不要忘记在 info.plist 中编辑“基于控制器的状态栏外观”并将其设置为 NO。

How can I give textcolor in status bar?如何在状态栏中提供文本颜色?

You can't!你不能!

The only thing that you could do is to change the UIStatusBarStyle , which could be one of the two following options:您唯一可以做的就是更改UIStatusBarStyle ,它可能是以下两个选项之一:

  • default : default

A dark status bar, intended for use on light backgrounds.深色状态栏,用于浅色背景。

在此处输入图片说明

  • lightContent : lightContent

A light status bar, intended for use on dark backgrounds.浅色状态栏,用于深色背景。

在此处输入图片说明

So, if you are aiming to change the color of the elements in the status bar (black color in first screenshot and white color in second screenshot) to gray -for instance-, that would be not possible, you have to stick of one of the mentioned two options.因此,如果您的目标是将状态栏中元素的颜色(第一个屏幕截图中的黑色和第二个屏幕截图中的白色)更改为灰色 - 例如,这是不可能的,您必须坚持其中一个提到的两个选项。


How to change the status bar style?如何更改状态栏样式?

You could check the following answered question to implement it:您可以检查以下已回答的问题来实施它:

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

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