I have a UITextField in which I want to display a clear button. UITextField cornerRadius has been changed and has no border. I also added a registration to the left and right of the text area. The following code leaves me without a clear button.
searchField.layer.cornerRadius = 15;
searchField.clearButtonMode = UITextFieldViewModeAlways;
UIView *padding = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 8, 20)];
searchField.leftView = padding;
searchField.leftViewMode = UITextFieldViewModeAlways;
searchField.rightView = padding;
searchField.rightViewMode = UITextFieldViewModeAlways;
[padding release];
[searchField addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged];
searchField.userInteractionEnabled = YES;
Does anyone know why I can’t get a button to display? I would appreciate any help.
Thank!
source
share