ghostrider
ghostrider

Reputation: 5259

alignment in textfield does not work

I want both my placeholder and typed text to be aligned in the center.

I tried both of these options for the two textfields I have, but still the placeholder and whatever I type are aligned left.

self.teamA_name.textAlignment=NSTextAlignmentCenter;
self.teamB_name.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

What am I missing?

Textfields are created through IB.

Upvotes: 0

Views: 83

Answers (1)

vijeesh
vijeesh

Reputation: 1325

UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,15, 20)];
_txtCityName.leftView = paddingView;
_txtCityName.leftViewMode = UITextFieldViewModeAlways;

Use this code to set inset..This works for me Currently I'm setting padding view width as 15...change this as your requirement and make it in the center

Upvotes: 1

Related Questions