3

Possible Duplicate:
Adding the “Clear” Button to an iPhone UITextField

hey there, i created a UITextField and i want to add an (X) -CLEAR- button to the right of it. The regular button that clears what is already written in the textfield. Thanks.

braX
  • 11,506
  • 5
  • 20
  • 33
Dani A
  • 31
  • 2

2 Answers2

5

set the clearButtonMode

field.clearButtonMode = UITextFieldViewModeAlways;
field.clearButtonMode = UITextFieldViewModeNever;
field.clearButtonMode = UITextFieldViewModeUnlessEditing;
field.clearButtonMode = UITextFieldViewModeWhileEditing;

or use Interface Builder, it has a setting for the clear button as well.

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
0

Set the text field's clearButtonMode. See here.

Alexsander Akers
  • 15,967
  • 12
  • 58
  • 83