0

I am trying to show a top bar in Xcode 9 Swift 4. In my storyboard it shows the top bar as in the below picture:

storyboard top bar

but when I run it I get this with no top bar:

enter image description here

I tried to use a navigation bar just with a title but it shows as:

enter image description here

the carrier, wifi, time, and battery background is still white. If I set the navigation bar to the top of the screen, it will cover them like:

enter image description here

Why the top bar is not showing? How can achieve something like this?:

enter image description here

UPDATE

Top bar is not a navigation bar. It is kind of just a bar that shows a title. As you can see in the below picture, the register scene doesn't have a navigation bar. I added the top bar from the properties on the right side.

enter image description here

Jumana Alhaddad
  • 285
  • 2
  • 6
  • 17

2 Answers2

1

In your second to last screen, where you show that the navigation bar covers it:

enter image description here

It does not really cover it - but the text of the status bar is black, so you cannot see it. To change it, in the implementation of the GrolocationNewsViewController (or whatever you call it) override preferredStatusBarStyle and return .lightContent:

class GrolocationNewsViewController: UIViewController {

    // rest of the code

    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
}
Milan Nosáľ
  • 19,169
  • 4
  • 55
  • 90
0

I have used the code from @Milan Nosáľ answer and it does show the status in white. Then used @Ameya Vichare answer on this link while I was looking for a way to increase the navigation bar height How to change navigationBar height in iOS 11? turn out it is a bug in Xcode 9. Now it shows like what I wanted:

enter image description here

Jumana Alhaddad
  • 285
  • 2
  • 6
  • 17