I have been search for over two days now and simply could't find an answer. Hope anyone out there can help?
- In short, the project I am working on holds a searchbar in its navigationbar.
- This searchbar is part part of a UISearchController that gets passed to the
searchControllerproperty of the view controller'snavigationItem(see code example). - Whatever I do, the search bar always appears with a gray tint.
- I set all possible background and tint colours to
.clearornilwith no luck. - Part of the challenge is that the searchbar has to stay in the navigation bar and cannot get placed anywhere else. All other space in the real navigation bar of the real project is already taken.
- I am suing Swift5 with minimum deployment iOS 14.
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
