Possible Duplicate:
Styling the cancel button in a UISearchBar
I am trying to set image for searchbar, I can set image for searchabar using searchbar's subview UISearchBarBackground
, but I am not able to set image for cancel button of searchbar. I get searchbar subview UINavigationButton
for button but I dnt knowhow to set image on UINavigationButton
. Can anyone help me?
Thank you in advance
try this code...
for (UIView *searchbuttons in searchBar.subviews)
{
if ([searchbuttons isKindOfClass:[UIButton class]])
{
UIButton *cancelButton = (UIButton*)searchbuttons;
cancelButton.enabled = YES;
[cancelButton setBackgroundImage:[UIImage imageNamed:@"yourImageName"] forState:UIControlStateNormal];
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With