Wednesday, 20 November 2013

Customise the UITextField clearButton colour:




change the color of a UITextField clearButton:




CGFloat myWidth = 25.0f;
    CGFloat myHeight = 25.0f;
    UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, myWidth, myHeight)];
    [myButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [myButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateHighlighted];
    
    [myButton addTarget:self action:@selector(doClear:) forControlEvents:UIControlEventTouchUpInside];
    
    myTextField.rightView = myButton;
    myTextField.rightViewMode = UITextFieldViewModeUnlessEditing;

No comments:

Post a Comment