更新时间:2022-06-25 23:57:08
将 UIView
添加到您的布局.这将是您的 UISearchBar
的容器.然后以编程方式实例化 UISearchController,然后将搜索栏添加到容器中:
Add a UIView
to your layout. That will be the container for your UISearchBar
. Then programmatically instantiate the UISearchController and then add the searchbar to the container:
let searchController = UISearchController(searchResultsController: searchResultsController)
searchBarContainer.addSubview(searchController.searchBar)