0

So, my search bar looks like this and it is invoked via a UISearchController. It's all working fine except for one thing. Find friends

Scrolling down the search list will show the results under the status bar as it is transparent, like this

...

I've used a couple of "ugly" fixes to get this looking and working as it and the problem clearly lies within the translucent = true - parameter. Can anyone see a quick solution to my problem? Other than jsut putting another empty, non-transparent view on top and make it white ofc. I've had another issue earlier today and the solution to this problem is the reason why this happens..

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"
    }
}
Community
  • 1
  • 1
Percolator
  • 513
  • 5
  • 25

1 Answers1

1

Try this:

self.edgesForExtendedLayout = UIRectEdgeNone;
Wujo
  • 1,845
  • 2
  • 25
  • 33