UISearchBar increases navigation bar height in iOS 11

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

    All solution didn't work for me so before I pushed view controller I did:

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    
        self.navigationItem.titleView = UIView()
    }
    

    And to make search bar present when going back:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        self.navigationItem.titleView = UISearchBar()
    }
    
    0 讨论(0)
提交回复
热议问题