How to left align UISearchBar placeholder text

ios, objective-c, uiimageview, uisearchbar

Solution

Don't use a `UISearchBar` if you need to do these kinds of customizations. You'll have to make your own using a `UITextField` and a `UIImageView`, and responding to the delegate calls.

Problem

I need to make a custom search bar like this. The problem I am having is left aligning the placeholder text, as well as placing the search icon in the right. I have a png of the search icon that I have tried to use in an `UIImageView`, and set that `UIImageView` as the `rightView` of the `UISearchBar`'s `UITextField`. This solution has not worked, and I ran out of ideas. Does anyone have a solution?

Original source

Related problems