使用 SearchController 推送 ViewController,在搜索栏下方显示黑色矩形
Pushing ViewController with SearchController showing black rectangle under Search Bar
当我将另一个控制器推入堆栈时(当有一个搜索控制器时)我在搜索栏下方看到一个黑色方块。我已将以下所有内容的背景颜色设置为白色;
- 搜索控制器
- 搜索栏
- 当前 VC
- 下一个VC
返回堆栈时也会出现。
搜索控制器
func setUpSearchController() {
searchController.delegate = self
searchController.view.backgroundColor = .white
searchController.searchBar.backgroundColor = .white
searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.sizeToFit()
searchController.searchBar.backgroundColor = .white
searchController.searchBar.barTintColor = .white
searchController.searchBar.placeholder = "Search"
searchController.searchBar.searchBarStyle = .minimal
searchController.searchBar.tintColor = Colours.brandGreen
definesPresentationContext = true
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
} else {
messagesTableView.tableHeaderView = searchController.searchBar
}
}
有没有 Select 小区
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let chatController = ChatController()
let message = messages[indexPath.row]
chatController.title = message
self.navigationController?.pushViewController(chatController, animated: true)
}
一如既往,非常感谢任何帮助。
在这里找到答案:
https://blog.kulman.sk/fixing-black-artifact-changing-large-tiles-mode/
代码
guard let navigationController = navigationController else { return }
navigationController.view.backgroundColor = .white
正如上面 link 解释的那样,这不能全局设置,因此,需要在我将使用的每个 NC 上设置。
当我将另一个控制器推入堆栈时(当有一个搜索控制器时)我在搜索栏下方看到一个黑色方块。我已将以下所有内容的背景颜色设置为白色;
- 搜索控制器
- 搜索栏
- 当前 VC
- 下一个VC
返回堆栈时也会出现。
搜索控制器
func setUpSearchController() {
searchController.delegate = self
searchController.view.backgroundColor = .white
searchController.searchBar.backgroundColor = .white
searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = true
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.sizeToFit()
searchController.searchBar.backgroundColor = .white
searchController.searchBar.barTintColor = .white
searchController.searchBar.placeholder = "Search"
searchController.searchBar.searchBarStyle = .minimal
searchController.searchBar.tintColor = Colours.brandGreen
definesPresentationContext = true
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true
} else {
messagesTableView.tableHeaderView = searchController.searchBar
}
}
有没有 Select 小区
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let chatController = ChatController()
let message = messages[indexPath.row]
chatController.title = message
self.navigationController?.pushViewController(chatController, animated: true)
}
一如既往,非常感谢任何帮助。
在这里找到答案: https://blog.kulman.sk/fixing-black-artifact-changing-large-tiles-mode/
代码
guard let navigationController = navigationController else { return }
navigationController.view.backgroundColor = .white
正如上面 link 解释的那样,这不能全局设置,因此,需要在我将使用的每个 NC 上设置。