Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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         break;      } } [self.searchBarHome setBackgroundColor:[UIColor clearColor]]; 
like image 577
Vikram Avatar asked Jan 08 '14 10:01

Vikram


People also ask

How do I change my search bar background?

From the control panel, select the search engine you want to edit. Click Look and feel from the menu on the left and then click the Themes tab. Select the theme you want to use. You can preview them in the box on the right.


1 Answers

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]; 
like image 147
staticVoidMan Avatar answered Sep 25 '22 13:09

staticVoidMan