Vikram Vikram - 1 year ago 131
iOS Question

Make UISearchBar background clear

I am not able to clear search bar I have tried to make it clear by setting its background color clear and I have also placed one image under searchbar

I have also made clear background of searchbar

for (UIView *subview in self.searchBarHome.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[subview removeFromSuperview];//please help me to make clear background of uisearchbar
[self.searchBarHome setBackgroundColor:[UIColor clearColor]];

Answer Source

For iOS7+, all you need to do is:

[self.searchBarHome setBackgroundColor:[UIColor clearColor]];
[self.searchBarHome setBarTintColor:[UIColor clearColor]]; //this is what you want

NOTE: This will not work for iOS6

For iOS6+, the following will take care of it even in iOS7:

[self.searchBarHome setBackgroundColor:[UIColor clearColor]];
[self.searchBarHome setBackgroundImage:[UIImage new]];
[self.searchBarHome setTranslucent:YES];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download