Horizontal position of UISearchBar when using UISearchController and large titles

258 Views Asked by At

UISearchController created and used like this in viewDidLoad

search = UISearchController(searchResultsController: nil)
search.searchResultsUpdater = self
search.obscuresBackgroundDuringPresentation = false
search.definesPresentationContext = true
search.searchBar.placeholder = "Search books"

navigationItem.searchController = search

I need to change horizontal position (offset, inset?) of the searchBar (search text field?) to align with title and content.

issue

I already tried to change the frame of searchBar in viewDidAppear (left pic below), but it goes back when text field becomes first responder (right pic).

frame changed in viewDidLoad frame is back when text field is first responder

Is there any working solution?

0

There are 0 best solutions below