title: How to customize the searchBar in a UISearchController?
body: <p>I know how to set the appearance for a independent <code>UISearchBar</code>, just like the following.</p>
  
  <pre><code>    let searchField = searchBar.value(forKey: "searchField") as? UITextField
  
      if let field = searchField {
          field.backgroundColor = UIColor.defaultBackgroundColor
          field.layer.cornerRadius = 15.0
          field.textColor = .white
          field.tintColor = .white
  
          field.font = UIFont.systemFont(ofSize: fl(13))
          field.layer.masksToBounds = true
          field.returnKeyType = .search
      }
  </code></pre>
  
  <p>But this is not working in the <code>UISearchController</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/EZj4B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EZj4B.png" alt="enter image description here"></a></p>
  
  <p>I want to set the text color of the placeholder and the left magnifying lens icon to pure white.
  (It seems there is a colored layer over them now).</p>
  
  <p>In addition, the input text is black now, I want it to be white too.  </p>
  
  <p>In a conclusion, I want to modify the following properties.<br>
  1. textField background color<br>
  2. textFiled placeholder text color<br>
  3. textFiled text color<br>
  4. textFiled font  </p>
  
  <p>Anyone know how do it?</p>
  
  <p>Add the following with your code in viewDidAppear:</p>
  
  <pre><code>            let placeholderString = NSAttributedString(string: "Placeholder", attributes: [NSAttributedStringKey.foregroundColor: UIColor.white])
              field.attributedPlaceholder = placeholderString
  
              let iconView = field.leftView as! UIImageView
              iconView.image = iconView.image?.withRenderingMode(.alwaysTemplate)
              iconView.tintColor = .white
  </code></pre>
  
  <p><strong>Updata:</strong><br>
  Put those settings in <code>ViewDidAppear()</code> did solve a part of my problem.<br>
  But the <code>textfield's background color</code> changed when I set the bar's background color.<br>
  Because <code>searchBar.barTintColor = .red</code> is not working in iOS11's <code>UISearchController</code> embedded in navigation item, I used <code>searchBar.backgroundColor = .red</code><br>
  It confused me a lot.<br>
  So how to change searchBar's background and textField's background separately?</p>