Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar black lines/border

I'm getting some odd black lines above and below a UISearchBar and I'm not quite sure how to get rid of them. Setting the style of the UISearchBar to minimal solves that problem, but then it doesn't have the background colour I'd like.

Any ideas what's causing this? I've looked over a few similar questions, but none seem to do what I want. Many thanks in advance!

Search bar showing a black border at the top and bottom

like image 596
Ben Avatar asked Sep 16 '15 16:09

Ben


3 Answers

Try this:

searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor blueColor] CGColor];
like image 90
Abhinav Avatar answered Nov 08 '22 03:11

Abhinav


For Swift 3:

searchBar.layer.borderWidth = 1
searchBar.layer.borderColor = searchBar.barTintColor?.cgColor
like image 22
p-sun Avatar answered Nov 08 '22 04:11

p-sun


By setting empty image to background will solve the issue

self.searchBar.backgroundImage = UIImage()
like image 3
miOS Avatar answered Nov 08 '22 05:11

miOS