iOS:UISearchBar显得有色

时间:2017-02-16 00:09:19

标签: ios swift uisearchbar ios10 uisearchdisplaycontroller

我对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()

这就是UISearchBar出现的方式:

enter image description here

激活:

enter image description here

我不知道我在哪里得到背景中的灰色。我继承了使用UIAppearence Proxy的代码库,但我没有看到UISearchBar的任何内容。也许,searchBar从其他地方继承它。

关于如何摆脱灰色的任何想法?

1 个答案:

答案 0 :(得分:0)

首先,删除所有这些:

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()

转到故事板并将Bar Tint更改为背景颜色。 http://imgur.com/a/YrJbX