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

strave picture strave · Oct 1, 2011 · Viewed 24.2k times · Source

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:

search bar with black bottom line

UPDATE:

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

Answer

Ayush Goel picture Ayush Goel · Jan 25, 2012

Try this

 searchBar.layer.borderWidth = 1;

 searchBar.layer.borderColor = [[UIColor lightGrayColor] CGColor];