Smooth fading iOS 11 search bar

I ran into a little problem, I implemented a new iOS 11-style search bar in my application, and I noticed that it disappeared with a slightly different animation than in messages, for example. It is faster and less smooth.

Has anyone ever stumbled upon this "problem"?

Here is the code I'm using:

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 this will help you, but I scroll at the usual pace. thank

+4
source share
2 answers
UIView.animate(withDuration: 1, animations: { 
//your codes to implement
}, completion: nil)

change withDuration: in seconds

0
source

, . , "" , .

0

Source: https://habr.com/ru/post/1694686/


All Articles