I have been search for over two days now and simply could't find an answer. Hope anyone out there can help?
searchController
property of the view controller's navigationItem
(see code example)..clear
or nil
with no luck.This sample code illustrates what we are using in our project:
class SearchControllerTests3: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
navigationItem.title = "Search Bar"
navigationController?.navigationBar.barTintColor = .white
navigationController?.navigationBar.backgroundColor = .white
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.layer.borderWidth = 0.2
let searchController = UISearchController()
searchController.searchBar.backgroundColor = .white
searchController.searchBar.tintColor = .white
searchController.searchBar.searchTextField.backgroundColor = .white
searchController.searchBar.searchTextField.tintColor = .white
navigationItem.searchController = searchController
}
}
The sample code above creates the following output when presented under a UINavigationController
After having searched for a long time, I did not find a way to fully customise a search bar that appears in the navigation bar as part of the a search bar controller.
I resolved this issue by removing the search bar controller and adding a normal UISearchBar
underneath the navigation bar. This set up gave me all the options I needed to gave the search bar the appearance I needed.