Mark Bourke Mark Bourke - 2 years ago 296
Swift Question

Change UINavigationBar Background Color of UISearchController

At the minute, my search controllers "navigation bar" background is the standard default translucent however, all the other bars in my app are black translucent. When I print the navigationController property of the searchController, it returns nil and so does the navigationBar, but not the navigationItem. There are no other public properties that seem to let you change the color of the bar. I don't mind overriding private ivars as I wont be releasing this app on the app store.

Answer Source

You can use the barTintColor property, in Swift this would be:

searchBar.barTintColor = UIColor.redColor()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download