12

With the iOS 13 update, I've got an annoying bug that I still wasn't able to solve when I have the prefersLargeTitles = true on my UINavigationBar and I perform a push segue. Plus, even if I'm not 100% sure if it's related to it, my view controller has a collection view embedded.

Anyway the bug/glitch I'm talking about is the following:

enter image description here

Basically the text doesn't animate as I would expect when I'm pushing, and it continues to stay there till the new screen is presented. Any tips? Thanks

Alessandro Francucci
  • 1,528
  • 17
  • 25

2 Answers2

28

I had the same issue. Try to set navigationItem.largeTitleDisplayMode to .always for your first VC and then .never for your second VC with prefersLargeTitles = true in both cases.

The reason is written from Apple Doc:

If the prefersLargeTitles property of the navigation bar is false, this property has no effect and the navigation item’s title is always displayed as a small title.

Which is causing the animation glitch, and it's not a iOS13 bug only, on iOS12/11 it's already the case it's just the other way around (the animation glitch is happening when dismissing from the secondVC back to the firstVC).

I wrote an article that explain a bit more about this: https://www.morningswiftui.com/blog/fix-large-title-animation-on-ios13

Thomas Sivilay
  • 316
  • 2
  • 5
0

Try to set largeTitleDisplayMode param inside viewWillAppear() method.

for the base VC set it to .always and in the destination VC set it to .never

BASE VC

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


DESTINATION VC

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