searchBar视图的UISearchController属性,如何删除黑色边框线?

时间:2016-05-27 03:28:23

标签: ios swift uisearchcontroller

在使用UISearchController时,尝试修改searchBar barTintColor属性,改变颜色。结果呈现两条黑线,效果如下图。

enter image description here

如何删除这两条黑线?

我的代码:

// 搜索结果控制器
searchVC = SearchViewController()

searchController = UISearchController(searchResultsController: searchVC)
// 设置UISearchController属性
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = true
// 设置UISearchBar属性
searchController.searchBar.delegate = self
searchController.searchBar.sizeToFit() //直接关系到searchBar会不会上推
searchController.searchBar.barTintColor = BackgroudGray
searchController.searchBar.tintColor = UIColor.yellowColor()

// 设置本ViewController
definesPresentationContext = true

tableView.tableHeaderView = searchController.searchBar

1 个答案:

答案 0 :(得分:2)

尝试这个

searchController.searchBar.backgroundImage = UIImage() searchController.searchBar.backgroundColor = UIColor.lightGray