I am working on Swift.
As regular SearchBar By default its appearing like Following Pic(1).

But as per our design requirement I need to change it as Following Pic(2).
I tried using the following code I got like Following Pic(3)
**When I tried the following code the right view is getting hide and I could not able to see the text field rightview
Search icon completely invisible**
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
Can anyone help me to get the requirement. I can understand if you provide even on objective C as well



Try This , and call on viewDidLayoutSubviews()