当我将另一个控制器推入堆栈时(使用搜索控制器时),搜索栏下方出现一个黑色方块。在以下所有内容中,我都将背景色设置为白色;
当它回到堆栈中时也会出现。
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
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let chatController = ChatController()
let message = messages[indexPath.row]
chatController.title = message
self.navigationController?.pushViewController(chatController, animated: true)
}
一如既往,任何帮助都将不胜感激。
答案 0 :(得分:5)
在这里找到答案: https://blog.kulman.sk/fixing-black-artifact-changing-large-tiles-mode/
guard let navigationController = navigationController else { return }
navigationController.view.backgroundColor = .white
如上面的链接所述,此设置无法全局设置,因此需要在我要使用的每个NC上。