UITextField custom background color clearButton

A chicken thief solutions for custom clearButton style, you can directly modify the background

1. Based UITextField's category and add the following methods and statement

 

- (void)setLightStyle:(BOOL)lightStyle {

    

    UIButton *clearButton = [self valueForKey:@"_clearButton"];

    [clearButton setImage:@"clearButton".image forState:0];

    [clearButton setImage:@"clearButton".image forState:1];

}

 

Perform a global style replacement program started after 2. Appdelegate

 

[[UITextField appearance] setLightStyle:YES];

 

3. surprise!!

 

Guess you like

Origin www.cnblogs.com/dev1024/p/9579002.html