jonjon
jonjon

Reputation: 11

Swift: Enable iOS11 large title navigation bar

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

Xcode screenshot

Upvotes: 1

Views: 4968

Answers (3)

user10900414
user10900414

Reputation:

override func viewDidLoad() {
    super.viewDidLoad()
    if #available(iOS 11, *) {
        self.navigationController?.navigationBar.prefersLargeTitles = true
    }
}

Upvotes: -2

BatyrCan
BatyrCan

Reputation: 6983

  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

Upvotes: 3

Matic
Matic

Reputation: 501

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.

Upvotes: 0

Related Questions