Chapter 38 - Search Bar Background

Not sure why, but I think in the new xCode 13, when you use a UISearchBar now, the search bar background isn’t white anymore but is a light grey by default. So when we change the appearance of the UISearchBar it doesn’t look appealing. Any idea how to fix this??

This is the result:


You can add this to the AppDelegate func customizeAppearance():

UITextField.appearance(whenContainedInInstancesOf: [UISearchBar. self ]).backgroundColor = .white

1 Like

AWESOME, thank you so much. Can you provide a bit of explanation as to why this solves the issue?

You’re welcome! I found the solution at It seems that it is changing the appearance of UITextFields, which are contained in a UISearchBar.
If someone can explain better, please do! :crazy_face:

This topic was automatically closed after 166 days. New replies are no longer allowed.