【发布时间】:2016-04-03 19:38:24
【问题描述】:
所以,我的搜索栏看起来像这样,它是通过UISearchController 调用的。除了一件事,一切都很好。
向下滚动搜索列表将在状态栏下显示结果,因为它是透明的,像这样
我已经使用了一些“丑陋”的修复来让它看起来和工作正常,问题显然在于translucent = true - 参数。谁能看到我的问题的快速解决方案?除了 jsut 将另一个空的、不透明的视图放在顶部并使其变为白色之外。我今天早些时候遇到了另一个问题,this 问题的解决方案就是发生这种情况的原因..
func willPresentSearchController(searchController: UISearchController) {
if let navBarFont = UIFont(name: "HelveticaNeue-Light", size: 25.0) {
let navBarAttributesDictionary: [String: AnyObject]? = [
NSForegroundColorAttributeName: PinkColor,
NSFontAttributeName: navBarFont
]
self.navigationController?.navigationBar.titleTextAttributes = navBarAttributesDictionary
}
self.navigationController?.navigationBar.translucent = true
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
searchController.searchBar.backgroundColor = UIColor.whiteColor()
self.navigationController?.navigationBar.topItem?.title = "Find Friends"
self.refreshControl?.backgroundColor = UIColor.whiteColor()
self.refreshControl?.tintColor = self.GrayColor
}
func willDismissSearchController(searchController: UISearchController) {
if let navBarFont = UIFont(name: "HelveticaNeue-Light", size: 25.0) {
let navBarAttributesDictionary: [String: AnyObject]? = [
NSForegroundColorAttributeName: UIColor.whiteColor(),
NSFontAttributeName: navBarFont
]
self.navigationController?.navigationBar.titleTextAttributes = navBarAttributesDictionary
}
UIView.animateWithDuration(0.3) { () -> Void in
self.navigationController?.navigationBar.translucent = false
self.navigationController?.navigationBar.backgroundColor = self.PinkColor
self.navigationController?.navigationBar.barTintColor = self.PinkColor
searchController.searchBar.backgroundColor = self.PinkColor
self.refreshControl?.backgroundColor = self.PinkColor
self.refreshControl?.tintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.topItem?.title = "Friends"
}
}
【问题讨论】:
标签: swift uitableview uinavigationbar uistatusbar