I have a UISearchBar to which I want to set a white background.
Since I want to set a custom border, I choose the minimal value for searchBarStyle.
I can obtain a white background by setting backgroundColor and borderStyle to the searchTextField (this field is only available in iOS 13, to access it safely in other iOS versions check here), as follows:
searchBar.searchTextField.borderStyle = .none
searchBar.searchTextField.backgroundColor = .white
However, this doesn't work in iOS 13, it seems that the background color is ignored when searchBarStyle value is minimal, but correctly works for default / prominent styles.