Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Bar Large Title - Animation Issue

I'm using the large title on the navigation bar, and when I tap on a cell to go on the next controller, the large title has a strange animation (as you can see on the gif below). It's doesn't disappear immediately.

I tried the following solution but nothing (https://www.morningswiftui.com/blog/fix-large-title-animation-on-ios13)

enter image description here

My Code:

On the first View Controller:

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        navigationItem.title = "New Order"
        navigationController?.navigationBar.prefersLargeTitles = true
}

On the Second View Controller (With the large title):

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        navigationItem.title = "Menu"
        self.navigationController?.navigationBar.prefersLargeTitles = false
}

Edit:

Fabio's answer is the solution but now I have another problem:

When I tap on a cell a part of the navigation bar is black (as you can see below)

enter image description here

like image 208
Alex Giatrakis Avatar asked Dec 06 '19 16:12

Alex Giatrakis


1 Answers

Try to insert On the first View Controller:

 override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    navigationItem.title = "New Order"
    navigationController?.navigationBar.prefersLargeTitles = true
    navigationItem.largeTitleDisplayMode =  .always
 }

and On the Second View Controller:

 override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    navigationItem.title = "Menu"
    navigationItem.largeTitleDisplayMode = .never
}
like image 179
Imed Ben Aoun Avatar answered Oct 31 '22 05:10

Imed Ben Aoun