Swift,UISearchBar多个问题,同时单击
我有两个问题。当我点击搜索栏时,背景并没有覆盖顶部空间的适当视图。而取消按钮仅在我第一次点击搜索栏时出现。如果我再次点击,取消按钮将消失。 也已附加快照 下面是我的代码 在viewDidLoad中Swift,UISearchBar多个问题,同时单击,swift,uisearchbar,Swift,Uisearchbar,我有两个问题。当我点击搜索栏时,背景并没有覆盖顶部空间的适当视图。而取消按钮仅在我第一次点击搜索栏时出现。如果我再次点击,取消按钮将消失。 也已附加快照 下面是我的代码 在viewDidLoad中 self.contactsTableView.delegate = self self.contactsTableView.dataSource = self self.resultSearchController = ({ let controlle
self.contactsTableView.delegate = self
self.contactsTableView.dataSource = self
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchBar.barTintColor = UIColor.whiteColor()
controller.searchResultsUpdater = self
controller.searchBar.delegate = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
self.contactsTableView.tableHeaderView = controller.searchBar
return controller
})()
self.contactsTableView.reloadData()
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
searchBar.frame = CGRectMake(0, 0, searchBar.frame.width, 44)
searchBar.tintColor = UIColor.whiteColor()
searchBar.backgroundColor = self.utility.uicolorFromHex(0x63003C)
searchBar.barTintColor = self.utility.uicolorFromHex(0x63003C)
}
func searchBarTextDidEndEditing(searchBar: UISearchBar) {
searchBar.tintColor = UIColor.whiteColor()
}
func searchBarCancelButtonClicked(searchBar: UISearchBar) {
searchBar.tintColor = UIColor.whiteColor()
searchBar.backgroundColor = UIColor.whiteColor()
searchBar.barTintColor = UIColor.whiteColor()
}
已按代码而不是情节提要包含UISearchBar控制器。
有人能帮我吗?有人有解决办法吗?有人有解决办法吗?