Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can background or borders be removed from UISearchBar?

I'd like to get something like this:

enter image description here

But I was not able to remove original background (I'm using iOS5). However, it seems Apple did it:

enter image description here

How can I create what I want? Or, there is no choice and the only alternative I have is customize a UITextField?

Thanks for suggestions and ideas!

EDIT: After first reply, this is what I got:

enter image description here

Does anyone how can I remove white inner background without making all component semitransparent changing its alpha value? BTW, can I change white color by black color?

like image 888
Ricardo Avatar asked Jun 07 '12 17:06

Ricardo


1 Answers

Try this code,It worked for me

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

In the above code yourSearchBar is the searchbar from which you want to remove the background, And the for loop is searching for the background image of UISearchBar

like image 192
Piyush Kashyap Avatar answered Sep 28 '22 15:09

Piyush Kashyap