I've built a search page that has a search controller as the navigationItem:
func configureSearchBar() {
navigationItem.searchController = searchController
searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
}
And in the searchController, I've specified a searchResultsController thats just an empty UIViewController atm with a cyan background:
let searchController = UISearchController(searchResultsController: ResultsTableViewController())
The searchResultsController is presented once the user begins typing, but for some reason, the searchResultsController is not taking up the full screen, even though I've set the modal presentation style to full screen:
func updateSearchResults(for searchController: UISearchController) {
guard let text = searchController.searchBar.text else { return }
let resultsController = searchController.searchResultsController as? ResultsTableViewController
resultsController?.modalPresentationStyle = .fullScreen
print(text)
}
Heres how it looks in app:
How can I correct this so that searchResultsController takes up the entire screen, without leaving that gap between the search bar, like it does now?

Setting modalPresentationStyle: It's not typical to set the modalPresentationStyle inside the updateSearchResults(for:) method. The modalPresentationStyle is usually set when presenting view controllers modally. If you intend to present a view controller in a specific presentation style, it's better to do it outside this method, possibly when the user selects a search result.