UISearchController 中的搜索图标被截断
Search Icon in UISearchController is Cutoff
当我将 UISearchController 搜索栏中的占位符文本更新为比搜索栏更宽的内容时,搜索图标会发生这种情况:
我通过在 viewDidLoad
中调用以下方法添加了 UISearchController 和搜索栏:
private func initSearchController() {
searchResultsController = UITableViewController()
searchResultsController.tableView.backgroundColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1.0)
searchController = UISearchController(searchResultsController: searchResultsController)
searchResultsController.tableView.rowHeight = 50
let textFieldInsideSearchBar = searchController.searchBar.valueForKey("searchField") as? UITextField
textFieldInsideSearchBar?.textColor = UIColor.whiteColor()
searchController.searchBar.sizeToFit()
searchController.searchBar.placeholder = "SOL Southwest Kitchen & Tequila Bar"
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.searchBarStyle = .Minimal
navigationItem.titleView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchResultsController.tableView.dataSource = self
searchResultsController.tableView.delegate = self
searchController.searchBar.delegate = self
}
什么给了?另外,无论如何要删除后退按钮和搜索栏之间的奇怪间隙?如果有帮助,这个视图是导航控制器中的第二个视图控制器。使用 iOS9 和 Swift 2.1。谢谢!
似乎这是不可能的,除非使用按钮、图像和文本字段创建自定义搜索栏。
当我将 UISearchController 搜索栏中的占位符文本更新为比搜索栏更宽的内容时,搜索图标会发生这种情况:
我通过在 viewDidLoad
中调用以下方法添加了 UISearchController 和搜索栏:
private func initSearchController() {
searchResultsController = UITableViewController()
searchResultsController.tableView.backgroundColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1.0)
searchController = UISearchController(searchResultsController: searchResultsController)
searchResultsController.tableView.rowHeight = 50
let textFieldInsideSearchBar = searchController.searchBar.valueForKey("searchField") as? UITextField
textFieldInsideSearchBar?.textColor = UIColor.whiteColor()
searchController.searchBar.sizeToFit()
searchController.searchBar.placeholder = "SOL Southwest Kitchen & Tequila Bar"
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.searchBarStyle = .Minimal
navigationItem.titleView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchResultsController.tableView.dataSource = self
searchResultsController.tableView.delegate = self
searchController.searchBar.delegate = self
}
什么给了?另外,无论如何要删除后退按钮和搜索栏之间的奇怪间隙?如果有帮助,这个视图是导航控制器中的第二个视图控制器。使用 iOS9 和 Swift 2.1。谢谢!
似乎这是不可能的,除非使用按钮、图像和文本字段创建自定义搜索栏。