[英]how to change the color of text in StatusBar
How to change the text color of status bar content. 如何更改状态栏内容的文本颜色。 i want color like yellow ,green etc. not system provided style I has changed the color of status bar but not changing the text color of status bar.
我想要黄色,绿色等颜色,而不是系统提供的样式。我已更改状态栏的颜色,但未更改状态栏的文本颜色。
You can switch between dark and light color by overriding preferredStatusBarStyle in a viewController: 您可以通过覆盖深色和浅色之间切换preferredStatusBarStyle中的viewController:
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
However, you have two options only, either .default
or .lightContent
, for dark text color and light text color, respectively. 但是,只有两个选项 ,
.default
或.lightContent
,分别用于深色文本颜色和浅色文本颜色。 You cannot use any color that you want. 您不能使用任何所需的颜色。 Although I can imagine implementing your own custom status bar, and hiding the system status bar - although you might have difficulties getting to all the system info that the system status bar presents.
尽管我可以想象实现自己的自定义状态栏并隐藏系统状态栏-尽管您可能难以获取系统状态栏显示的所有系统信息。
you can change using below code . 您可以使用以下代码进行更改。 Place this code in app Delegate in method
将此代码放在方法中的应用程序委托中
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.appearance().barStyle = .blackTranslucent
}
or 要么
UINavigationBar.appearance().barStyle =.lightContent
You can't set custom color to it . 您无法为其设置自定义颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.