Purpose:
Modify the "Cancel" button on the Uisearchbar to "cancel" and modify the color, character, and font theory of the Cancel button : The first view in the array is obtained by getting all view data on the Searchbar, which is to cancel button. When you get to the button, you can change any element of the Cancel button. Code implementation:
For (UIView *viewin [[[Searchbar subviews]objectatindex:0]subviews]) {
if ([viewiskindofclass:[ Nsclassfromstring (@ "Uinavigationbutton") class]) {
UIButton * Cancel = (UIButton *) view;
[Cancel settitle:@ "cancels" forstate:uicontrolstatenormal];
Modify text color
[cancel Settitlecolor:[uicolorwhitecolor] forstate:uicontrolstatenormal];
[Cancel Settitlecolor:[uicolorwhitecolor] forstate:uicontrolstatehighlighted];
Modify button Background
[Cancel setbackgroundimage:[uiimageimagenamed:@ "Btn_cancel.png"]forstate:uicontrolstatenormal];
[Cancel setBackgroundImage:nilforState:UIControlStateHighlighted];
}