Reputation: 293
I was wondering if it was possible to change the default text in a text field in a xib file when the field is selected.
For example the placeholder would be "Phone number" in grey and then after the user selects the field it changes to "+44" in black?
Thanks,
Feras
Upvotes: 4
Views: 841
Reputation: 2329
This should be achievable by changing text attribute in didBeginEditing function of the UITextField's delegate like this:
extension YourClass : UITextFieldDelegate {
func textFieldDidBeginEditing(_ textField: UITextField) {
textField.text = "+44"
}
}
Upvotes: 5