Reputation: 6402
I have a UITextfield to enter a card number, of length 16. But i need to format the pin number as 1234 ** * *** at the time of entering. Can anyone help me with this?
Upvotes: 0
Views: 616
Reputation: 18368
You can read this sample code on GitHub.
It implements the UIKeyInput
protocol to produce a custom input view.
Upvotes: 0
Reputation: 542
Do you mean u want the digits to be asterisk?
if yes just go on to your xib file click the textfield
and go to inspector attributes and check the secure button.
hope thats what u want
Upvotes: 1
Reputation: 4732
if it is ok, thet there will be spaces to separate numbers:
[text addTarget:self action:@selector(textFieldEditing:) forControlEvents:UIControlEventEditingChanged];
- (IBAction)textFieldEditing:(id)sender {
//separate string of your TextField text and add spaces where you whant
[sender setText:(NSString *)]
}
Upvotes: 0
Reputation: 1416
you can try adding an observer to UITextFieldTextDidChangeNotification; every time that notification is fired, you can re-format the input.
Upvotes: 0