Is there a native UI control for code input text field, for example like Whatsapp:
Is there a native UI control for code input text field, for example like Whatsapp:
No there isn't. Use a UITextField
, fill it with dashes, keep track of how many characters the user has entered, and replace the dashes accordingly as the user types.
No. To achieve this, they're almost certainly tapping into the textField:shouldChangeCharactersInRange:replacementString: method for their UITextField
, selectively accepting and formatting user input to match the dash-if-empty approach.
Further, I'm sure they've subclassed the field; per your comments there isn't a blue cursor - which isn't standard for a UITextField
.
There's a 4-digit code input text field called CodeInputView written in Swift.
In the past I've added a UITextField to the view and set its hidden == true. Then I show/hide the keyboard by calling becomeFirstResponder()/resignFirstResponder() on it. I listen for text did change notifications and update a visible label with the value of the hidden text field.