Mark Bourke Mark Bourke - 7 months ago 112
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

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

searchBar.barTintColor = UIColor.redColor()
Comments