I have been implementing a UISearchController, I add it to the navigationItem of the view. When the view loads, it is hidden until I scroll down to show it. I want it to be shown initially. I have changed the navigationItem.hidesSearchBarWhenScrolling to false, it solved the initial problem but I also want it to be hidden when the user is scrolling through the collectionView of the view. I am currently using Swift 6 and iOS 18+. I will add the current configuration function.
private 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
navigationItem.hidesSearchBarWhenScrolling = false
}