Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 13 - Buggy Large Title UINavigationBar while pushing

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

like image 496
Alessandro Francucci Avatar asked Oct 04 '19 10:10

Alessandro Francucci


2 Answers

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

like image 162
Thomas Sivilay Avatar answered Nov 15 '22 18:11

Thomas Sivilay


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
 }
like image 21
Alpexs Avatar answered Nov 15 '22 20:11

Alpexs