I am trying to create a UINavigationController with a UISearchController similar to the one in this screenshot.

However, it ends up being rendered like the following screenshot:

I am not sure why the gap is being rendered.
I have the following code to set up the UISearchController:
func configureSearchController() {
let searchController = UISearchController()
searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = "Search for a username"
searchController.obscuresBackgroundDuringPresentation = false
navigationItem.searchController = searchController
}