I'm creating a textField and adding it to a view like this:
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(/*blah blah */)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.clearButtonMode = UITextFieldViewModeAlways;
[otherView addSubview:textField];
The text field is rendered as expected in otherView
, but the clear button is never rendered, no matter what value I assign to clearButton. Anyone know what might be causing this?
The answer is that UITextField.clearButtonMode
works. When the text field has a value, the button is there. I guess I assumed "Always" means "Always", when it really means, "when .text != nil
".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With