Reputation: 1834
I want to resize the default clear button of UITextField
. After I googled a lot, I came to know there is no way to modify it.
So I decided to go with Custom option ie, by adding UIButton
to text field.I found some code from S.O, but nothing works for me. These are the links which I referred.
So please suggest some solution which behaves exactly as default clear button of UITextField
Any help will be appreciated.
Thanks in advance.
Upvotes: 1
Views: 3338
Reputation: 7633
In addition to the jake9115 response, you can emulate the clearbutton behavior by using the UITextFieldDelegate callbacks.
You can try in this way:
Show the button when -textFieldDidBeginEditing
: is called
Hide the button when -textFieldDidEndEditing:
is called
Hide the button if in -(BOOL)textFieldShouldClear:(UITextField*)textField
the length
of the textField's text
is 0.
Upvotes: 3
Reputation: 4084
Why not just make a button that sets the TextView's value to ""?
- (IBAction)button:(id)sender {
_myTextView.text = "";
}
Upvotes: 2