Friday, January 5, 2018

How to adjust constraints with collapsing SearchBar in large iOS11 NavigationBar

Leave a Comment

How do I adjust the constraint when pushing a new UIViewController when a UISearchController is implemented as self.navigationItem.searchController = search

enter image description here

New controller pushed: SearchBar collapses but leaves View with constrait to top = 0 on the initial position.

(The background of the ViewController is yellow for easy understanding of the matter)

enter image description here

Implementation:

viewDidLoad() {  if #available(iOS 11.0, *) {     let search = UISearchController(searchResultsController: nil)     search.searchResultsUpdater = self     search.definesPresentationContext = true     search.hidesNavigationBarDuringPresentation = false      search.searchBar.tintColor = UI.COLOR_WHITE     search.dimsBackgroundDuringPresentation = false     self.navigationItem.hidesSearchBarWhenScrolling = false     self.navigationItem.searchController = search } 

I have tried using self.automaticallyAdjustsScrollViewInsets = false without success and the tableView implements self.contentInsetAdjustmentBehavior = .always

What am I missing? Help is very appreciated.

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment