1

From iOS 11 (and above) i try to incorporate large titles (with UISearchController). One of my screen doesn't have a UITableView as first child on the hierarchy (but rather UIPageViewController, this cause that the navigationBar is not collapsed because the scrollView is not the first child.. but due to structure design can't.. anyway that's not an issue).

When another screen is pushed (and that screen has navigationItem's largeTitleDisplayMode set to never), the transition animation looks weird (the UISearchBar is closed from the center and is not in sync with the navigationBar animation).

Note: If the controller that is pushed has largeTitleDisplayMode set to .automatic (or always) the transition is ok.

Background

When the prefersLargeTitle is enabled, navigationItem's searchController is set and the first view on the hierarchy is not a tableView (or i guess scrollView descendent), the navigationBar shows the searchBar open.

Options Tried

I tried modifying the translucent property of the UINavigationBar and UISearchBar. Also set the UINavigationBar's clipToBounds.

Code

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.navigationBar.prefersLargeTitles = true
        self.navigationItem.largeTitleDisplayMode = .always
        navigationItem.searchController = UISearchController(searchResultsController: nil)
    }

}
class SecondViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationItem.largeTitleDisplayMode = .never
    }

}

enter image description here

0 Answers0