IOS UISearchBar Background Color In iOS 9

ios, ios9, search, swift

Solution

Swift 3

To remove the background altogether, set `backgroundImage` to an empty image:

searchBar.backgroundImage = UIImage()

To set a custom background color, use `barTintcolor` property:

searchBar.barTintColor = .green

Problem

I have been search a while for this issue , I want my search bar display like BBC News App I try all related method ``` for view in searchBar.subviews { if view.isKindOfClass(NSClassFromString("UISearchBarBackground")!) { view.removeFromSuperview() break; } } self.searchBar.tintColor = UIColor.clearColor() self.searchBar.backgroundColor = UIColor.clearColor() self.searchBar.translucent = true ``` here is my output Am I miss something ??? Please Help me , thx !

Original source

Related problems