BlueChips23 BlueChips23 - 1 year ago 113
iOS Question

How to implement UISearchBar with no border

I am trying to add a UISearchBar without the border around it, but it's simply not working.

This is what I have:

On the XIB file, I added UISearchBar. Style = Black Transparent. Tint = Default. None of the options (bookmarks, cancel button, scope bar, etc) are selected. Background = Default. Drawing = opaque (basically the default setting of the UISearchBar).

I have a property for UISearchBar - searchBar.
In the implementation file, when the view loads, I have:

[[self.searchBar.subviews objectAtIndex:0] removeFromSuperview];

But for whatever reason, the background (the dark border around the box) is simply not going.
I tried [[self.searchBar.subviews objectAtIndex:0] setAlpha:0], but that's not working at all either.

Any help please?


Here is the code .....

for (id img in searchBar.subviews)
     if ([img isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
            [img removeFromSuperview];    

happy coding :)