Transition to Large Title from Small title shows small title for a moment in the destination view controller

1.3k Views Asked by At

I have two view controller in a navigation controller. The root view controller has small title and the next view controller has large title.

When I push the next view controller, I set

self.navigationItem.largeTitleDisplayMode = .always

In the viewDidLoad of next view controller. The problem is, when transitioning it shows the title as small for a moment and then the title becomes big. But I just want to show the big title. I tried setting the title text in ViewDidAppear, it kind of works but the title appears late. I don't want that too.

2

There are 2 best solutions below

0
On

Say you are doing something like this in vc1

let vc2 = SomeVC()
vc2.navigationItem.largeTitleDisplayMode = .always
self.navigationController.pushViewController(vc2, animated: true)

So try to set the property before pushing the viewcontroller

0
On

Had the same issue, I did this :

In VC 1 :

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationItem.largeTitleDisplayMode = .never
}

In VC 2 :

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationItem.largeTitleDisplayMode = .always
    navigationController?.navigationBar.prefersLargeTitles = true
}