On iOS 7 UISearchBar the placeholder text is centred and I want to disable that and make it always stick to the left like it was before.
I haven't tried it with a UISearchBar
but this works with a UITextField
. I Subclassed it and overrode leftViewRectForBounds:
, textRectForBounds:
and editingRectForBounds:
, here is the code:
- (CGRect)textRectForBounds:(CGRect)bounds {
CGRect inset = CGRectMake(bounds.origin.x + kLeftTextPadding,
bounds.origin.y,
bounds.size.width - kLeftTextPadding,
bounds.size.height);
return inset;
}
Hope it helps.