Add a UIView to your layout. This will be the container for your UISearchBar . Then programmatically create an instance of UISearchController, and then add the search string to the container:
let searchController = UISearchController(searchResultsController: searchResultsController) searchBarContainer.addSubview(searchController.searchBar)
source share