0

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;

Heron
  • 1
  • 2

1 Answers1

1

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

Martin Muldoon
  • 3,388
  • 4
  • 24
  • 55