Reputation: 14857
I have a UITextField
to let the user type 4 numbers which are returned from text message.I have set UITextField
style and background image correctly but have no idea how to arrange these four numbers nicely.What I want is this:
But the result is this:
Here is my setting for UITextField
.
How to separate the numbers nicely when typing from the keyboard,Any helps?
Upvotes: 1
Views: 42
Reputation: 13312
I propose to use NSKernAttributeName
attribute:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"1234"];
[attributedString addAttribute:NSKernAttributeName value:@(30) range:NSMakeRange(0, 4)];
self.textField.attributedText = attributedString;
Upvotes: 1
Reputation: 1407
I would advice you place four text fields in one view, give it rounded corners and add it to your view hierarchy. Your view will have your desired background, and your text fields will be transparent (clearColor). Then, in your delegate, when in one textfield text entered, move your coursor to the next text field
Upvotes: 0