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!
Try this:
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor blueColor] CGColor];
For Swift 3:
searchBar.layer.borderWidth = 1
searchBar.layer.borderColor = searchBar.barTintColor?.cgColor
By setting empty image to background will solve the issue
self.searchBar.backgroundImage = UIImage()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With