I have a UISearchBar as seen below. How can I change the text color for the cancel button?
Gyanerdra's answer works well. But for iOS7 I needed to make the following change for it work in my app.
NSArray *childViews;
if ( (APP).isIOS7 ) {
childViews = [[searchBar.subviews objectAtIndex:0] subviews];
} else {
childViews =searchBar.subviews;
}
for (UIView *subView in childViews ) {
if([subView isKindOfClass:[UIButton class]]){
[(UIButton *)subView setTintColor:desiredColor];
[(UIButton *)subView setTitleColor:desiredColor forState:UIControlStateNormal];
}
}
It seems that for iOS7 the search bar is enclosed in a parent view. Hope this helps someone. b