Valdemart
Valdemart

Reputation: 19

How to completely hide title bar but not navigation bar in iOS 13 Swift

I have a problem with my app development in Xcode 11.3. I'm developing an app targeting iOS 13.2, and I've edited the navigation bar so that its background is black. However, I can't seem to find a way to delete or hide the title bar. Now it just looks like a big black bar.

All the other content is served over a webview, so that's why I'd need to remove the title bar but not the black background color in the navigation bar (where the time and battery, etc. are displayed). I hope you can help.

Here's the preview currently:

Preview image of my app

Thanks!

Upvotes: 1

Views: 1582

Answers (1)

matt
matt

Reputation: 534903

So it sounds like you want something like this:

enter image description here

So, in that screen shot:

  • We're in a navigation interface, but the navigation bar is hidden.

  • The green view is a stand-in for your "Aleksis" view. Its top is pinned to the bottom of the safe area.

  • There is also a black view. Its top is pinned to the top of its superview (the view controller's main view) and its bottom is pinned to the bottom of the safe area. It is behind the green view.

Here's the storyboard configuration I used:

enter image description here

Here's the view controller code:

override var preferredStatusBarStyle: UIStatusBarStyle { .lightContent }
override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.isNavigationBarHidden = true
}

Upvotes: 3

Related Questions