我尝试将UISearchBarController添加到tableView,但是当我设置UINavigationBar.appearance()。translucent = false然后UISearchBar隐藏在屏幕之外
TableViewController中的
var resultSearchC: UISearchController = UISearchController()
override func viewDidLoad() {
super.viewDidLoad()
self.resultSearchC = ({
let c = UISearchController(searchResultsController: nil)
c.searchResultsUpdater = self
c.searchBar.translucent = true
c.searchBar.barTintColor = .redColor()
c.searchBar.sizeToFit()
self.tableView.tableHeaderView = c.searchBar
return c
})()
// self.edgesForExtendedLayout = .None
self.tableView.reloadData()
}
的AppDelegate:
let navBarAppearance = UINavigationBar.appearance()
navBarAppearance.barStyle = .Black
navBarAppearance.translucent = false
答案 0 :(得分:8)
您需要在viewDidLoad()中将extendedLayoutIncludesOpaqueBars设置为true。
extendedLayoutIncludesOpaqueBars = true;