iOS: UISearchBar appears tinted

104 Views Asked by At

I have the following settings for the UISearchBar:

            searchBar?.tintColor = UIColor.clear
            searchBar?.barTintColor = UIColor.clear
            searchBar?.backgroundColor = UIColor.clear
            searchBar?.layer.backgroundColor = UIColor.clear.cgColor
            searchBar?.layer.borderColor = UIColor.clear.cgColor
            searchBar?.layer.shadowColor = UIColor.clear.cgColor
            searchBar?.backgroundImage = UIImage()

And this is how the UISearchBar appears:

enter image description here

Activated:

enter image description here

I am not sure where I am getting the gray in the background. I have inherited a codebase that's using UIAppearence Proxy, but I don't see anything for UISearchBar. Perhaps, the searchBar is inheriting it from elsewhere.

Any ideas on how to get rid of the the gray color?

1

There are 1 best solutions below

3
J Manuel On

First, delete all this:

searchBar?.tintColor = UIColor.clear
            searchBar?.barTintColor = UIColor.clear
            searchBar?.backgroundColor = UIColor.clear
            searchBar?.layer.backgroundColor = UIColor.clear.cgColor
            searchBar?.layer.borderColor = UIColor.clear.cgColor
            searchBar?.layer.shadowColor = UIColor.clear.cgColor
            searchBar?.backgroundImage = UIImage()

Go to the Storyboard and change Bar Tint to your background color. http://imgur.com/a/YrJbX