原文链接:http://blog.csdn.net/lincsdnnet/article/details/53896841
如果传入的searchResultsController为nil,则表示搜索的结果在当前控制器中显示,现在我让它在searchResultVC中显示
// 创建searchResultVC let searchResultVC = UIViewController() // 设置背景颜色为红色 searchResultVC.view.backgroundColor = UIColor.red let searchController = UISearchController(searchResultsController: searchResultVC) // 设置背景颜色 searchController.view.backgroundColor = UIColor (red: 0.97, green: 0.97, blue: 0.97, alpha: 1.0) // 默认为YES,设置开始搜索时背景显示与否 // searchController.dimsBackgroundDuringPresentation = false // 默认为YES,控制搜索时,是否隐藏导航栏 // searchController.hidesNavigationBarDuringPresentation = false // 将搜索框视图设置为tableView的tableHeaderView tableView.tableHeaderView = searchController.searchBar