Henny Lee
Henny Lee

Reputation: 3052

Navigationbar title

In my current project, my navigation controller title doesn't seem to update / change. To see what's wrong I've created a new project and embedded a navigation controller to the view controller.

override func viewDidAppear(animated: Bool) {
    print(navigationController) // Optional(<UINavigationController: 0x7b356200>)

    navigationController?.navigationItem.title = "Main"
    navigationController?.navigationBar.backgroundColor = UIColor.greenColor()
}

Strangely the navigation bar changes to green but still there is no title. What could be the cause of this?

Upvotes: 0

Views: 104

Answers (1)

hannad
hannad

Reputation: 822

Replace your line with this

navigationController?.navigationBar.topItem?.title = "Main"

Upvotes: 2

Related Questions