strave strave - 10 months ago 46
iOS Question

Customize UISearchBar: Trying to get rid of the 1px black line underneath the search bar

My question is already specified in the title: I would like to get rid of the black line drawn on the bottom of the

. Any ideas?

Here's an image of what I mean:

search bar with black bottom line


I think that the line is part of the
. I still don't know how to remove it.


I fixed this by adding a subview to the searchBar's view stack like so:

CGRect rect = self.searchBar.frame;
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, rect.size.height-2,rect.size.width, 2)];
lineView.backgroundColor = [UIColor whiteColor];
[self.searchBar addSubview:lineView];

Here, self.searchBar is an UISearchBar pointer of my controller class.