简体   繁体   English

使用 Swift 导航 controller 状态栏内容颜色未变为白色

[英]Status Bar Content colour not changing to white in navigation controller using Swift

I have used UINavigationController to create navigation flow, first screen is List view controller and second one is detail view controller of list item.我使用 UINavigationController 创建导航流程,第一个屏幕是列表视图 controller,第二个屏幕是列表项的详细视图 controller。

I am hiding navigation bar in both view controllers because I have created my own top bar.我在两个视图控制器中都隐藏了导航栏,因为我创建了自己的顶栏。

Now I am trying to change status bar content to light content but现在我正在尝试将状态栏内容更改为轻量级内容,但是

override var preferredStatusBarStyle: UIStatusBarStyle{
   .lightContent
}

This is not getting called.这没有被调用。 I read multiple answers about changing status bar content style when UINavigationController is used but none of them help because I am hiding navigation bar.当使用 UINavigationController 时,我阅读了有关更改状态栏内容样式的多个答案,但它们都没有帮助,因为我隐藏了导航栏。

Navigation controller is embedded in TabBarController.导航 controller 嵌入在 TabBarController 中。

Attaching the image for reference Image附上图片以供参考图片

First hide navigation bar in viewDidLoad() by hit the below code首先通过点击以下代码在viewDidLoad()中隐藏导航栏

self.navigationController?.navigationBarHidden = true

Add the status bar code in ViewController like you did像你一样在ViewController中添加状态栏代码

override var preferredStatusBarStyle: UIStatusBarStyle{
   return .lightContent
}

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

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