1

I am working on UISearchBar which I have created programmatically. Below is what I am having an issue with:

http://oi46.tinypic.com/2lo25qu.jpg

How can I get rid of that line on this search bar?

The code is as following:

[self setBackgroundColor:[UIColor clearColor]];
[self setBarStyle:UIBarStyleDefault];
[self setTintColor:[UIColor whiteColor]];
[self setShowsCancelButton:NO];
paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
topgun
  • 2,463
  • 8
  • 31
  • 46
  • 1
    please show us some relevant code to help you out . – limon Aug 16 '12 at 21:43
  • This has been asked and solved here:[Customize UISearchBar](http://stackoverflow.com/questions/7620564/customize-uisearchbar-trying-to-get-rid-of-1px-black-line-underneath-the-search?rq=1) – SethHB Aug 16 '12 at 23:30

3 Answers3

0

You are setting the background color as clearColor. You can remove the background view of UISearchBar instead :

for(UIView *view in [searchBar subviews]){
    if([view isKindOfClass:NSClassFromString(@"UISearchBarBackground")]){
        [view removeFromSuperview];
    }
}

// in the above code in place of "searchBar" you have to use "self"
Msonic
  • 1,456
  • 15
  • 25
Ganee....
  • 302
  • 2
  • 13
0

You can use

  [[UISearchBar appearance] setSearchFieldBackgroundImage:[UIImage imageNamed:@"someImage.png"]forState:UIControlStateNormal];

on iOS 5+ to get rid of the line.

Andrew
  • 3,166
  • 21
  • 32
0

What I did was change the backing layer:

self.searchBar.layer.borderWidth = 1;
self.searchBar.layer.borderColor = [[UIColor redColor] CGColor];
nicktmro
  • 2,298
  • 2
  • 22
  • 31