My question is already specified in the title: I would like to get rid of the black line drawn on the bottom of the UISearchBar
. Any ideas?
Here's an image of what I mean:
UPDATE:
I think that the line is part of the UITableView
's tableHeaderView
. I still don't know how to remove it.
Try this
searchBar.layer.borderWidth = 1;
searchBar.layer.borderColor = [[UIColor lightGrayColor] CGColor];
So, I've dug into the API's trying to figure out why this is happening. Apparently whomever wrote the UISearchBar
API is rasterizing the lines onto an image and setting it as it's backgroundImage
.
I propose a simpler solution, if you want to set the backgroundColor
and get rid of the hairlines:
searchBar.backgroundColor = <#... some color #>
searchBar.backgroundImage = [UIImage new];
Or if you just need a background image without the hairlines:
searchBar.backgroundImage = <#... some image #>
I have 0.5px
black horizontal lines both on top and on the bottom of my UISearchBar
. The only way I had so far to get rid of them is by setting its style to Minimal
:
mySearchBar.searchBarStyle = UISearchBarStyleMinimal;
Solution for
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