Q:

search bar text field background color swift

I have a problem with change the color of the search bar text field.  I tried a lot of variations to change that color, but always I have a grey background on that text field.  Any ideas on how I can solve it?  Thanks! 
private func setupSearchBar(){
    searchBarOutlet.layer.cornerRadius = 6
    searchBarOutlet.layer.masksToBounds = true
    searchBarOutlet.layer.borderWidth = 1.5
    searchBarOutlet.layer.borderColor = UIColor.init(hexFromString: "7E5BEB").cgColor
    searchBarOutlet.isTranslucent = true
    if #available(iOS 13.0, *) {
        searchBarOutlet.searchTextField.backgroundColor = .white
        searchBarOutlet.searchTextField.tokenBackgroundColor = .white
        searchBarOutlet.searchTextField.tintColor = .clear
    } else {
        searchBarOutlet.textField.textColor = .black
        searchBarOutlet.textField.backgroundColor = .white
        searchBarOutlet.textField.tintColor = .white
    }
    searchBarOutlet.backgroundColor = .white
    searchBarOutlet.barTintColor = .white
    searchBarOutlet.setImage(#imageLiteral(resourceName: "Search icon"), for: .search, state: .normal)
}

A:

You can simply set the barTintColor of the UISearchBar instance to your required color, i.e.
searchBarOutlet.barTintColor = .white

And use backgroundColor change the background color of the searchTextField
searchBarOutlet.searchTextField.backgroundColor = .white

So, the below code works fine as per your requirement
searchBarOutlet.layer.cornerRadius = 6
searchBarOutlet.layer.masksToBounds = true
searchBarOutlet.layer.borderWidth = 1.5
searchBarOutlet.layer.borderColor = UIColor.init(hexFromString: "7E5BEB").cgColor
searchBarOutlet.isTranslucent = true
searchBarOutlet.barTintColor = .white
searchBarOutlet.searchTextField.backgroundColor = .white

Screenshot:

