title: How to change color of Search Bar?
body: <p>I've implemented a Search Bar and I want to change color of Search Bar. How can I do that?</p>
  
  <p>I've tried with: </p>
  
  <pre><code>self.mySearchBar.backgroundColor = [UIColor redColor];
  </code></pre>
  
  <p>but with no success.</p>
  
  <p><strong>UPDATE (Solved):</strong></p>
  
  <p>I had to remove the default background color before I defined background color with the following code.</p>
  
  <pre><code>for (UIView *subview in mySearchBar.subviews) {
      if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
          [subview removeFromSuperview];
          break;
      }
  } 
  </code></pre>
  
  <p>... so code would be next:</p>
  
  <pre><code>  for (UIView *subview in mySearchBar.subviews) {
        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
            [subview removeFromSuperview];
            break;
        }
    } 
  
    self.mySearchBar.backgroundColor = [UIColor redColor];
  </code></pre>