UISearchBar increases navigation bar height in iOS 11

后端 未结 19 1582
醉酒成梦
醉酒成梦 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:15

    I fixed this by added the constraint to viewDidAppear on the map view controller where the search bar is embedded

    public override func viewDidAppear(_ animated: Bool) {
        if #available(iOS 11.0, *) {
    
            resultSearchController?.searchBar.heightAnchor.constraint(equalToConstant: 44).isActive = true
            // searchBar.heightAnchor.constraint(equalToConstant: 44).isActive = true
        }
    }
    

提交回复
热议问题