title: How to add a custom image for the textfield in UIsearchbar iOS swift
body: <p>I am trying to create a custom search bar. I want to add a custom image for the textfield in the search bar. I set the searchbarstyle minimal. I used the following code to change the background image. it doesn't fit well. This outlets are added programmatically</p>
  
  <pre><code>let srchtextfld: UITextField = srchbr.valueForKey("searchField") as! UITextField
  
      srchtextfld.layer.backgroundColor = UIColor(patternImage: UIImage(named: "Rounded Rectangle 1 copy 3.png")!).CGColor
  </code></pre>
  
  <p>I am Getting the below image</p>
  
  <p><a href="https://i.stack.imgur.com/D04Qp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D04Qp.png" alt="enter image description here"></a></p>
  
  <p>I want to add this type of image as its background</p>
  
  <p><a href="https://i.stack.imgur.com/mxUqi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxUqi.png" alt="enter image description here"></a></p>
  
  <p>Any help is appreciated</p>