user10034296
user10034296

Reputation: 179

Trying to set background color of UISearchController in Swift 5

I am trying to set the background color of a UISearchController in Swift 5.

I have tried methods mentioned in other threads but I believe they are outdated.

    searchController.barTintColor = UIColor.redColor()

Error Message: Value of type 'UISearchController' has no member 'barTintColor'

Upvotes: 0

Views: 378

Answers (1)

Celeste
Celeste

Reputation: 1577

    searchController.searchBar.barTintColor = UIColor.red
    searchController.searchBar.searchBarStyle = .default

i.e
if your searchBarStyle is .minimal, you won’t be able to change the barTintColor. It will remain white.

Upvotes: 4

Related Questions