简体   繁体   中英

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:

在此处输入图像描述

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

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

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
 }

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:

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM