I added UISearchController programmatically with code
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Введіть значення для пошуку"
searchController.searchBar.backgroundColor = .white
navigationItem.searchController = searchController
definesPresentationContext = true
}
But it seems that it is not centered vertically. How can I fix it?
Connected SearchController to TableView instead of NavigationItem
tableView.tableHeaderView = searchController.searchBar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With