iosswiftanimationuisearchbarios13

Weired animation of tableview and searchbar of UISearchController embed in navigationbar


I've embed UISearchController into the navigationbar and my view controller has the table view. When I click on searchbar and keyboard appears tableview and searchbar does not animate smoothly. It seems like searchbar is overlaping navigationbar.

Here is the code,

Declare searchcontroller as a variable like,

var resultSearchController = UISearchController()

and defination in viewDidLoad is like,

self.resultSearchController = ({
        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.obscuresBackgroundDuringPresentation = false;
        self.navigationItem.searchController = controller
        return controller
    })()

Animation issue is like below gif(watch till end to see slow animation)

enter image description here

I want same duration for animation for tableview, navigation bar, and searchbar.

Any help will be appreciated.


Solution

  • Don't set UITableView top anchor to be pinned to safeArea but to superview.