KZY
KZY

Reputation: 91

Why is there a white line on UISearchController when click on the search bar?

enter image description here

enter image description here enter image description here

As you can see from the picture, there is a white line when you search bar is click. I had try to set the background image to UIImage and clear all the shadow image but still this white line keep coming out when the search bar click and animate.

Pooja Gupta solution result:

enter image description here

This is the code that i use to customise the navigation bar

 [[UINavigationBar appearance] setBarTintColor:barColor];
[[UINavigationBar appearance] setTintColor:buttonColor];

Upvotes: 5

Views: 835

Answers (3)

NakCheon Owen Jung
NakCheon Owen Jung

Reputation: 178

I had a same issue. When scrolling down scrollview there was a white line between navi-bar and search bar. By inspecting UI hierarchy I found out that there is a gap between them.

The color of the gap would be other view's background color, like tableview, collection, or webview. In my project case there is a webview. So I put a backgoround color same as navigation bar's tint color on webview's scrollview. Then problem solved!

enter image description here

Upvotes: 1

Marco Tini
Marco Tini

Reputation: 21

Try to customise the colour through the Storyboard and not from the code. You see that the white row disappear (I don't know how but it does).

See the image https://i.sstatic.net/lGlJu.png

Upvotes: 0

Pooja Gupta
Pooja Gupta

Reputation: 793

You can add border as your background color

 UIColor bgColor = [UIColor blueColor]; // This is your background color.     
_searchBar.layer.borderWidth = 1.0;
_searchBar.layer.borderColor = bgColor.CGColor;

Upvotes: 1

Related Questions