在使用UISearchController时,尝试修改searchBar barTintColor属性,改变颜色。结果呈现两条黑线,效果如下图。
如何删除这两条黑线?
我的代码:
// 搜索结果控制器
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
答案 0 :(得分:2)
尝试这个
searchController.searchBar.backgroundImage = UIImage() searchController.searchBar.backgroundColor = UIColor.lightGray