Some apps have this nice little white circle with an gray x in there UITextField. How can I add this to an UITextField and delete the text when it is tapped?
views:
24answers:
2
+1
A:
To add a button like this, you can use the clearButtonMode property of an UITextField.
The code will be like this:
// Show cancel button never
textField.clearButtonMode = UITextFieldViewModeNever;
// Show cancel button only when you're editing text in textField
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
// Show the cancel button only when you aren't editing the text
textField.clearButtonMode = UITextFieldViewModeUnlessEditing;
// Show always the cancel button
textField.clearButtonMode = UITextFieldViewModeAlways;
Matthew
2010-09-25 16:39:54