When I push another controller on to the stack (When having a Search Controller) I get a black block under the search bar. I have set the background colour to white on all the below;
It also appears when going back in the stack.
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)
}
As always any help greatly appreciated.
Found the answer here: https://blog.kulman.sk/fixing-black-artifact-changing-large-tiles-mode/
guard let navigationController = navigationController else { return }
navigationController.view.backgroundColor = .white
As the above link explains this cannot be set globally, therefore, would need to be on each NC I will be using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With