3

There is a code that creates the Search Bar. After there is a click on this Search Bar, then it is shifted down along with the "Cancel" button. I enclose screenshots and code.

before click

after click

@IBAction func showSearchBar(_ sender: UIBarButtonItem) {
   self.navigationItem.setRightBarButtonItems([], animated: true)

   self.searchController = UISearchController(searchResultsController: nil)

   self.searchController.searchResultsUpdater = self 
   self.searchController.searchBar.delegate = self 
   self.searchController.delegate = self

   self.searchController.hidesNavigationBarDuringPresentation = false
   self.searchController.obscuresBackgroundDuringPresentation = true
   self.searchController.dimsBackgroundDuringPresentation = false
   self.searchController.searchBar.placeholder = "Искать продукты"

   self.searchController.searchBar.setShowsCancelButton(true, animated: true)
   self.searchController.searchBar.searchBarStyle = .minimal

   self.navigationItem.titleView = searchController.searchBar
   self.definesPresentationContext = true
}

How to fix it?

Tkas
  • 302
  • 3
  • 14

0 Answers0