标签:背景 uri 控制器 stat data 按钮 load setimage alpha
// 创建searchResultVC
let searchVC = UIViewController()
// 设置背景颜色为红色
searchVC.view.backgroundColor = UIColor.red
let searchController = UISearchController(searchResultsController: searchVC)
// 设置背景颜色
searchController.view.backgroundColor = UIColor (red: 0.97, green: 0.97, blue: 0.97, alpha: 1.0)
// 默认为YES,设置开始搜索时背景显示与否
// searchController.dimsBackgroundDuringPresentation = false
// 默认为YES,控制搜索时,是否隐藏导航栏
// searchController.hidesNavigationBarDuringPresentation = false
// 将搜索框视图设置为tableView的tableHeaderView
tableView.tableHeaderView = searchController.searchBar
// 搜索框
let bar = searchController.searchBar
// 样式
bar.barStyle = .default
// 设置光标及取消按钮的颜色
bar.tintColor = RGBA(r: 0.12, g: 0.74, b: 0.13, a: 1.00)
// 设置代理
bar.delegate = self
// 去除背景及上下两条横线
bar.setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
// 右侧语音
bar.showsBookmarkButton = true
bar.setImage(#imageLiteral(resourceName: "VoiceSearchStartBtn"), for: .bookmark, state: .normal)
// MARK:- UISearchBarDelegate
extension LXFContactViewController: UISearchBarDelegate {
func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar) {
LXFLog("点击了语音按钮")
}
}
iOS - Swift UISearchController仿微信搜索框
标签:背景 uri 控制器 stat data 按钮 load setimage alpha
原文地址:http://www.cnblogs.com/YunCalc/p/6413946.html