UISearchBar increases navigation bar height in iOS 11

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

    I tried various things to get the size back to the original 44, but then the search bar always looks and behaves weird - like being to far stretched, y-offset and alike.

    I found a nice solution here (via some other stackoverflow post): https://github.com/DreamTravelingLight/searchBarDemo

    Just derive your viewcontroller from the SearchViewController and include in your project the SearchViewController and WMSearchbar classes. Worked out of the box for me without any ugly if (iOS11) else... uglyness.

提交回复
热议问题