Rehaan Advani
Rehaan Advani

Reputation: 975

Remove space between UISearchBar and UINavigationBar (Swift)

Originally, I wanted the tint color of my search bar to be the same as the color of the navigation bar. However, the navigation bar has a transparent effect, and this affects the saturation of the color. So, I set the transparent property of the navigation bar to false. Now, they are the same color, but there is this large space between the two:enter image description here

How do I get rid of this space?

EDIT: COULD THIS BE BECAUSE OF A UITABLEVIEW I HAVE THAT IS IN THIS VIEW? EDIT: enter image description here

Upvotes: 1

Views: 916

Answers (1)

benjamin.ludwig
benjamin.ludwig

Reputation: 1585

If you are using autolayout, this looks like the searchbar has a top constraint of 0 to the top layout guide. I don't know if this is a bug, but it causes the padding.

Make the top constraint 0 to the superview instead of the top layout guide or try a top constraint with a negative value (-20 - 44 = -64) to the top layout guide.

Upvotes: 2

Related Questions