Question: I've implemented a Search Bar and I want to change color of Search Bar. How can I do that?

I've tried with: 

```
self.mySearchBar.backgroundColor = [UIColor redColor];

```

but with no success.

**UPDATE (Solved):**

I had to remove the default background color before I defined background color with the following code.

```
for (UIView *subview in mySearchBar.subviews) {
    if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
        [subview removeFromSuperview];
        break;
    }
} 

```

... so code would be next:

```
  for (UIView *subview in mySearchBar.subviews) {
      if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
          [subview removeFromSuperview];
          break;
      }
  } 

  self.mySearchBar.backgroundColor = [UIColor redColor];

```

Answer: 
```
self.mySearchBar.backgroundColor = [UIColor redColor]; 

```

won't do anything,

but

```
self.mySearchBar.tintColor = [UIColor redColor]; 

```

will!
```
    self.mySearchBar.backgroundVolor = [UIColor redColor];

```

"Volor" or "Color 

```
  self.mySearchBar.backgroundColor = [UIColor redColor];

```

Also if you want to tint it:

According to the documentation : <https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISearchBar_Class/Reference/Reference.html>, there is a tintColor property on the UISearchBar class.

In the TableSearch example: <https://developer.apple.com/library/ios/#samplecode/TableSearch/> the search bar is defined and loaded in the MainView.xib. If you want to change its tintColor or style, just do it in the xib and it will be loaded into the application.

BUT THE ONLY REAL WAY to change background color is to override it, look at the answer from the following question

[UISearchBar clear background color or set background image [iphone sdk]](https://stackoverflow.com/questions/2139115/uisearchbar-clear-background-color-or-set-background-image-iphone-sdk)