ios – UISearchBar at all times seems with grey tint when positioned in navigation bar by way of a search bar controller


I’ve been seek for over two days now and easily might’t discover a solution. Hope anybody on the market can assist?

  1. Briefly, the undertaking I’m engaged on holds a searchbar in its navigationbar.
  2. This searchbar is a component a part of a UISearchController that will get handed to the searchController property of the view controller’s navigationItem (see code instance).
  3. No matter I do, the search bar at all times seems with a grey tint.
  4. I set all doable background and tint colors to .clear or nil with no luck.
  5. A part of the problem is that the searchbar has to remain within the navigation bar and can’t get positioned anyplace else. All different house in the true navigation bar of the true undertaking is already taken.
  6. I’m suing Swift5 with minimal deployment iOS 14.

This pattern code illustrates what we’re utilizing in our undertaking:

class SearchControllerTests3: UIViewController {
    override func viewDidLoad() {
        tremendous.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 pattern code above creates the next output when offered underneath a UINavigationController

enter image description here

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles