1

How can I enable an ios11 large title navigation bar? This is not working.

Xcode screenshot

rmaddy
  • 314,917
  • 42
  • 532
  • 579
jonjon
  • 11
  • 1
  • 2

3 Answers3

3
  1. Select ViewController
  2. Editor -> Embed in -> Navigation Controller
  3. Select NavigationController, select navigation bar
  4. Tick "Prefers Large titles" from attributes inspector

enter image description here

Community
  • 1
  • 1
BatyrCan
  • 6,773
  • 2
  • 14
  • 23
  • 1
    What if I dont want to put my MyViewController inside a UINavigationController ? I just want a NavBar that has the LargeTitle Style. What he did is dragged a NavBar from the Controls, probably to customize it. – omarojo Mar 13 '19 at 23:29
0
self.title = "Your title"
    if #available(iOS 11, *) {
        self.navigationController?.navigationBar.prefersLargeTitles = true
        self.navigationController?.navigationItem.largeTitleDisplayMode = .always
    } 

Please note that if you want to test this out you need at least:

  • Xcode 9.0,
  • Mac OSX - 10.12.6 or later,
  • iPhone/iPad or Xcode 9 simulator with iOS 11.
Matic
  • 393
  • 3
  • 12
  • 1
    That's because the above is assuming your ViewController is inside a UINavigationController, and is not. You dragged a custom NavBar into your ViewController. You are making a custom NavBar that is just a UIView. for some reason the IB ignores the checkbox for largeTitles – omarojo Mar 13 '19 at 23:27
-2
override func viewDidLoad() {
    super.viewDidLoad()
    if #available(iOS 11, *) {
        self.navigationController?.navigationBar.prefersLargeTitles = true
    }
}
  • He is draggin and dropping a NavBar into his ViewController (not a UINavigationController). So what you posted is not going to work. – omarojo Mar 13 '19 at 23:25