title: iOS 11 UISearchBar in UINavigationBar
body: <p>I want to place a search bar in the new navigation bar with the new iOS 11 large titles. However, the color of the search bar is automatically applied by iOS and I can't change it. </p>
  
  <pre><code>if #available(iOS 11.0, *) {
      let sc = UISearchController(searchResultsController: nil)
      navigationItem.searchController = sc
      navigationItem.hidesSearchBarWhenScrolling = false
  }
  </code></pre>
  
  <p>The search bar get's a deep blue background, but I just want to change it to white. </p>
  
  <p><a href="https://i.stack.imgur.com/ydeCw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ydeCw.png" alt="enter image description here"></a></p>
  
  <p>Setting the background color results in this:</p>
  
  <pre><code>navigationItem.searchController?.searchBar.backgroundColor = UIColor.white
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IzhAE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IzhAE.png" alt="enter image description here"></a></p>
  
  <p>I have tried also <code>setScopeBarButtonBackgroundImage</code> and <code>setBackgroundImage</code> on the search bar but everything looks totally weird.</p>
  
  <p>Also when I trigger the search by tapping on the search bar, it switches to a mode with the cancel button on the right side. ("Abbrechen" in German)</p>
  
  <p><a href="https://i.stack.imgur.com/vrN0C.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vrN0C.png" alt="enter image description here"></a></p>
  
  <p>And the "Abbrechen" text color also can't be changed. (need it also white)</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Edit: As requested, here the code for the navigation bar styling:</p>
  
  <pre><code>self.navigationBar.tintColor = UIColor.myWhite
  self.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.myWhite, NSAttributedStringKey.font: UIFont.myNavigationBarTitle()]
  self.navigationBar.barTintColor = UIColor.myTint
  
  if #available(iOS 11.0, *) {
      self.navigationBar.prefersLargeTitles = true
      self.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.myWhite, NSAttributedStringKey.font: UIFont.myNavigationBarLargeTitle()]
  }
  </code></pre>
  
  <p>Current outcome:
  I have used Krunals idea to set the color of the search bar background but then the rounded corners are lost. After re-setting the rounded corners the animation of the search bar seems to be broken.</p>
  
  <p><a href="https://i.stack.imgur.com/V3OhP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V3OhP.png" alt="enter image description here"></a></p>
  
  <p>So still no satisfactory solution. Seems that the search bar when embedded into the navigation bar in iOS 11 is not possible to customize. Meanwhile it would be enough for me to just change the color of the placeholder text, but even this seems not to be possible. (I have tried multiple approaches from StackOverflow - doesn't work)</p>