iOS顶部栏没有显示

时间:2018-02-06 01:06:46

标签: ios xcode

我正在尝试在Xcode 9 Swift 4中显示顶部栏。在我的故事板中,它显示了顶部栏,如下图所示:

storyboard top bar

但是当我运行它时我没有顶栏:

enter image description here

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

enter image description here

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

enter image description here

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

enter image description here

更新

顶栏不是导航栏。这只是一个显示标题的酒吧。如下图所示,寄存器场景没有导航栏。我在右侧的属性中添加了顶栏。

enter image description here

2 个答案:

答案 0 :(得分:1)

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

enter image description here

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

class GrolocationNewsViewController: UIViewController {

    // rest of the code

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}

答案 1 :(得分:0)

我使用了@MilanNosáľ回答中的代码,它确实以白色显示状态。然后在我正在寻找增加导航栏高度的方法时,在此链接上使用@Ameya Vichare回答 How to change navigationBar height in iOS 11?结果证明这是Xcode 9中的一个错误。现在它显示了我想要的内容:

enter image description here

相关问题