title: How to set UiSearchBar Search icon on the right side in swift
body: <p>I am working on Swift.</p>
  
  <p>As regular SearchBar By default its appearing like Following Pic(1).
  <a href="https://i.stack.imgur.com/RfNr1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RfNr1.png" alt="enter image description here"></a></p>
  
  <p>But as per our design requirement I need to change it as Following Pic(2).</p>
  
  <p><a href="https://i.stack.imgur.com/ESwkr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ESwkr.png" alt="enter image description here"></a></p>
  
  <p>I tried using the following code I got like Following Pic(3)</p>
  
  <p><a href="https://i.stack.imgur.com/HT8Bx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HT8Bx.png" alt="enter image description here"></a></p>
  
  <p>**When I tried the following code the right view is getting hide and I could not able to see the text field rightview</p>
  
  <p>Search icon completely invisible**</p>
  
  <pre><code>let searchField = (searchBar.valueForKey("_searchField") as! UITextField)
  searchField.layer.cornerRadius = 15;
  
  
      let searchIcon = searchField.leftView!
      if (searchIcon is UIImageView) {
          print("yes")
      }
  
      searchField.rightView = searchIcon
    searchField.leftViewMode = .Never
  searchField.rightViewMode = .Always
  </code></pre>
  
  <p>Can anyone help me to get the requirement. I can understand if you provide even on objective C as well</p>