Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth disappearance of iOS 11 search bar

I am running into a small problem, I implemented the new iOS 11's style search bar in my app, and I noticed that it disappeared with a slightly different animation from the one in Messages for example. It's faster and less smooth.

Anyone has ever stumble upon this "problem" ?

Here is the code I use :

searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.delegate = self

if #available(iOS 11.0, *) {
    navigationItem.searchController = searchController
} else {
    tableView.tableHeaderView = searchController.searchBar
    searchController.searchBar.barTintColor = .white
    searchController.searchBar.layer.borderColor = UIColor.white.cgColor
    searchController.searchBar.layer.borderWidth = 1
}
definesPresentationContext = true
searchController.searchBar.placeholder = "all_search".localized

EDIT: enter image description here

I don't know if it will help you, but I am scrolling at a normal pace . Thanks

like image 223
Nicolas Charvoz Avatar asked Mar 09 '18 13:03

Nicolas Charvoz


1 Answers

Adding

self.extendedLayoutIncludesOpaqueBars = true

to my viewDidLoad solved the issue, your navigation bar must not be translucent and note that extendedLayoutIncludesOpaqueBars = true is being attributed to my main view which holds the tableview.

like image 57
Douglas Pfeifer Avatar answered Oct 24 '22 18:10

Douglas Pfeifer