Chandler De Angelis Chandler De Angelis - 4 months ago 447
iOS Question

How to left align UISearchBar placeholder text

This is the searchbar that the designers want me to create

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?

Answer

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.