以下是配置搜索栏的代码:
代码:
searchController = UISearchController(searchResultsController:nil)
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search"
searchController.searchBar.delegate = self
searchController.searchBar.sizeToFit()
searchController.searchBar.translatesAutoresizingMaskIntoConstraints = true
searchBarContainerView.addSubview(searchController.searchBar)
它在iOS 9中运行良好。
但是在iOS 10中,它的高度突然增加并且与标题重叠。