因此,我的搜索栏看起来像这样,并通过UISearchController
调用。除了一件事,它一切正常。
向下滚动搜索列表会在状态栏下显示结果,因为它是透明的,如此
我使用了几个"丑陋的"修复了这个看起来和工作的问题,问题显然在translucent = true
- 参数内。任何人都可以看到我的问题的快速解决方案?除了jsut在顶部放置另一个空的,不透明的视图并使其成为白色ofc。我今天早些时候遇到了另一个问题,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"
}
}
答案 0 :(得分:1)
试试这个:
self.edgesForExtendedLayout = UIRectEdgeNone;