Make UISearchBar background clear

ios, objective-c, uisearchbar

Solution

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];

Problem

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 break; } } [self.searchBarHome setBackgroundColor:[UIColor clearColor]]; ```

Original source