iOS 顶部栏不显示

标签 ios xcode

我试图在 Xcode 9 Swift 4 中显示顶部栏。在我的 Storyboard中,它显示顶部栏,如下图所示:

storyboard top bar

但是当我运行它时,我得到的是没有顶部栏的:

enter image description here

我尝试使用带有标题的导航栏,但它显示为:

enter image description here

运营商、wifi、时间和电池背景仍然是白色。如果我将导航栏设置到屏幕顶部,它将像这样覆盖它们:

enter image description here

为什么顶部栏没有显示?如何实现这样的目标?:

enter image description here

更新

顶部栏不是导航栏。它只是一个显示标题的栏。如下图所示,注册场景没有导航栏。我从右侧的属性中添加了顶部栏。

enter image description here

最佳答案

在倒数第二个屏幕中,导航栏覆盖了它:

enter image description here

它并没有真正覆盖它——但是状态栏的文本是黑色的,所以你看不到它。要更改它,请在 GrolocationNewsViewController(或任何您称之为它的名称)的实现中覆盖 preferredStatusBarStyle 并返回 .lightContent:

class GrolocationNewsViewController: UIViewController {

    // rest of the code

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}

关于iOS 顶部栏不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48633953/

相关文章:

ios - XCode 8 将 View 放大到 Storyboard 中的 ScrollView

ios - Apple 企业开发者帐户可以使用 TestFlight Distribution 吗?

ios - 如何根据我的方案更改 .plist 条目?

xcode - 通过productbuild和pkgbuild修改文件所有权

ios - 如何实现通用的 do-try-catch block 以捕获操作中抛出的所有错误

ios - Swift 正确使用 getter 和 setter

ios - 将 NSDictionary 键排序为 NSDate

iphone - iOS 崩溃报告 "Hardware Model"到底是什么意思?

c++ - md5.h 文件未找到错误 Xcode 7 for Mac 应用程序

ios -::i-block-chrome css 技巧在 Mac 上不起作用