UISearchBarController iOS 11 issue - SearchBar and scope buttons overlap

后端 未结 7 858
误落风尘
误落风尘 2021-01-04 07:26

Referred here and here. No answer in first link. In the second link, though the answer is not accepted, but the link to apple developer forum gives error.

Before i

7条回答
  •  时光说笑
    2021-01-04 07:32

    I think that the solution is to add the Search Bar in the Navigation Bar:

    navigationController?.navigationBar.prefersLargeTitles = true // Navigation bar large titles
    navigationItem.title = "Contacts"
    navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
    navigationController?.navigationBar.barTintColor = UIColor(displayP3Red: 0/255, green: 150/255, blue: 136/255, alpha: 1.0)
    
    let searchController = UISearchController(searchResultsController: nil) // Search Controller
    navigationItem.hidesSearchBarWhenScrolling = false
    navigationItem.searchController = searchController
    

    You can find an example for UISearchBarController - SearchBar and scope buttons overlap here.

提交回复
热议问题