How to add a gap to a UISearchController?

51 Views Asked by At

I've added a search controller using the storyboard and added in the search controller programmatically. I'm having a bit of trouble centering the search bar vertically so that it's not touching the top navigation bar (see photo). How I added the search bar code is posted below.

Any help is appreciated.

self.navigationItem.searchController = self.searchController; self.navigationItem.hidesSearchBarWhenScrolling = NO;

1

There are 1 best solutions below

0
Martin Muldoon On

Simply add a vertical constraint to your search bar as I've done in this image:

enter image description here

You can set the vertical constraint by clicking the tie-fighter like icon at the bottom of XCode. Set your constraint to 8 for example then click the I-bar followed by add 1 constraint:

enter image description here