title: Change the background of UISearchBar's textField
body: <p>I'm struggling with this for a while now. Have searched everywhere but the solution provided only works with objective-c. Which consists in</p>
  
  <p><code>UITextField *txt = [_searchBar valueForKey:@"_searchField"];</code></p>
  
  <p>Although some might say that this is protected API and Apple might refuse an app with such code.</p>
  
  <p>So, now I've tried so many ways to work this out and it's not working at all.
  My code is this:</p>
  
  <pre><code>searchBar = UISearchBar(frame: CGRectMake(0, 0, 320.0, 30.0))
  searchBar.autoresizingMask = UIViewAutoresizing.FlexibleWidth
  searchBar.searchBarStyle = UISearchBarStyle.Minimal
  searchBar.layer.cornerRadius = 15
  searchBar.delegate = self
  
  searchBar.backgroundColor = UIColor.whiteColor()
  
  if floor(NSFoundationVersionNumber) &lt;= NSFoundationVersionNumber_iOS_6_1{
      // Load resources for iOS 6.1 or earlier
      searchBar.placeholder = "Search";
  } else {
      // The following "hack" (if we can call that) breaks the UI for different size devices.
      // Load resources for iOS 7 or later
      searchBar.placeholder = "Search                                         ";
  }
  </code></pre>
  
  <p>This gives me the bizarre result:
  <img src="https://i.stack.imgur.com/yNyoa.png" alt="enter image description here"></p>
  
  <p>While what I want is just the textfield inside the UISearchBar to have a white background and the SearchBar itself have a cornerRadius of, say, 15.</p>
  
  <p>How can I do this?</p>
  
  <p>Thanks so much in advance</p>