title: Swift - Customizing UISearchBar design programmatically
body: <p>I'm trying to customize UISearchBar design programmatically. I tried adding a bunch of codes but only a few places are changed.</p>
  
  <p>This is the design I want to create.</p>
  
  <p><a href="https://i.stack.imgur.com/0bdMo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0bdMo.jpg" alt="enter image description here"></a></p>
  
  <p>And this is how it looks now.</p>
  
  <p><a href="https://i.stack.imgur.com/Krlvk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Krlvk.jpg" alt="enter image description here"></a></p>
  
  <p><em>I screen-captured the second image from the simulator so it's bigger.</em></p>
  
  <p>Anyways, I'm trying to make my search bar has</p>
  
  <ol>
  <li>Lighter background color</li>
  <li>Shorter textfield in height</li>
  <li>Textfield to have less corner radious</li>
  </ol>
  
  <p>Here are my codes:</p>
  
  <pre><code>let searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 60))
  
      [In viewDidLoad()]
      searchBar.delegate = self
      searchBar.isTranslucent = false
      searchBar.placeholder = "Search the phrase"
      searchBar.tintColor = UIColor(red:0.73, green:0.76, blue:0.78, alpha:1.0)
      searchBar.setImage(UIImage(named: "search"), for: .search, state: .normal)
  
      let forTextField = searchBar.value(forKey: "searchField") as? UITextField
      forTextField?.textColor = UIColor(red:0.31, green:0.31, blue:0.31, alpha:1.0)
      forTextField?.font = UIFont(name: "HelveticaNeue-Light", size: 14)
      forTextField?.clipsToBounds = true
      forTextField?.layer.cornerRadius = 5
      forTextField?.frame.size.height = 30
  </code></pre>
  
  <p>I would appreciate your help!</p>