Reputation: 135
By default, the placeholder and icon of UISearchBar are left aligned. I want them to be centered like so:
On click of the search bar, the search text should also be centered.
I don't want to use offset because the alignment should dynamically change based on the length of the search text and the width of the phone. For example, if the UISearchBar has been clicked but no text is entered, the icon should right be in the middle.
Is there any solution - preferably not using offset - to center the search bar icon, search text, and placeholder?
Thank you
Upvotes: 0
Views: 535
Reputation: 244
Don't use a UISearchBar, in the context of these kinds of customisations. You'll have to make your own using a UITextField and a UIImageView, and responding to the delegate calls.
Upvotes: 0