UISearchBar presented by UISearchController in table header view animates too far when active

后端 未结 15 1025
长情又很酷
长情又很酷 2020-11-29 01:28

I am using UISearchController to present a search bar inside the header view of a tableview:

...
self.searchController.hidesNavigationBarDuringPresentation =         


        
相关标签:
15条回答
  • 2020-11-29 02:07

    If you use UINavigationController and TabBar you can't use:

    self.extendedLayoutIncludesOpaqueBars = true
    

    You would need this solution: https://stackoverflow.com/a/46151063/3369381

    0 讨论(0)
  • 2020-11-29 02:12

    In my case, setting the nav bar to self.navigationController.navigationBar.translucent = NO; fixed the problem. It seems that the search bar presentation layer doesn't take into account the translucence of the nav bar when laying out the search bar.

    I realize this isn't a perfect solution, because the translucence of the nav bar can throw off layout elsewhere, but it at least fixes the problem in the case where a non-translucent nav bar is a possibility.

    0 讨论(0)
  • 2020-11-29 02:12

    As mentioned in the first post everyone needed a different solution. So here is mine. I had to combine two things mentioned on this page, namely:

    Swift 2:

        navigationController?.navigationBar.translucent = true
    
        edgesForExtendedLayout = .None
    
    0 讨论(0)
提交回复
热议问题