Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image for Cancel button of UISearchbar [duplicate]

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

like image 929
user7388 Avatar asked Dec 24 '12 09:12

user7388


1 Answers

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;
        }
    }
like image 61
Paras Joshi Avatar answered Nov 06 '22 07:11

Paras Joshi