UISearchBar increases navigation bar height in iOS 11

后端 未结 19 1581
醉酒成梦
醉酒成梦 2020-11-28 02:47

I have my UISearchBar being part of the navigation bar like:

 let searchBar = UISearchBar()
 //some more configuration to the search bar
 .....
         


        
19条回答
  •  无人及你
    2020-11-28 03:21

    This happen to me too, all running well in iOS 12.4 and getting weird in 13 above. The problem is in iOS 13 navigation bar height increase from 88 to 100 after jump from UIViewController that implement searchBar.

    Try this in your UIViewController that implement searchBar.

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        navigationController?.view.setNeedsLayout()
        navigationController?.view.layoutIfNeeded()
    }
    

    Preview after fixing:

    Preview before fixing:

提交回复
热议问题