title: Change UISearchBar magnify icon color and position
body: <p>I have a UISearchBar and I would like to change the position of the initial magnify icon (the one that appears in the middle of the UISearchBar) as well as the color or icon.</p>
  
  <p>So far I changed the tint and the icon image. </p>
  
  <p>However, the new icon shows up only if I test the app on a simulator but on an actual device(both run iOS 9.3) it still shows the default icon. </p>
  
  <pre><code>UISearchBar.appearance().setImage(UIImage(named: "SearchbarIcon"), forSearchBarIcon: UISearchBarIcon.Search, state: UIControlState.Normal)
  </code></pre>
  
  <p>As for the magnify icon position, I want it in the left side, where it shows up if I activate the UISearchBar.</p>
  
  <p><a href="https://i.stack.imgur.com/fDymw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fDymw.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/LPHFF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LPHFF.png" alt="enter image description here"></a></p>
  
  <p>I found quite a lot of answers around here many of the provided solutions don't work on iOS 8.0+ or are in Objective-C and I am having some problems understanding them.</p>
  
  <p>I tried to add a custom background containing the icon but it shows up at the bottom of the search bar while the icon is still there:</p>
  
  <p><a href="https://i.stack.imgur.com/4gTe7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4gTe7.png" alt="enter image description here"></a></p>
  
  <p>The background shows up OK if I change the background offset for Y to -44 (the height of the UISearchBar) but I can no longer type since it seems the entire text field is pushed up. I also tried to change the vertical offset for the SearchText to 44 to compensate but no luck. To be honest, I am not sure what Search Text and the Background offsets are supposed to do but I decided to give them a try.</p>
  
  <p><a href="https://i.stack.imgur.com/twzEe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/twzEe.png" alt="enter image description here"></a></p>
  
  <p>Is there any way to accomplish this? Or maybe a different approach?</p>