HurkNburkS HurkNburkS - 1 year ago 207
iOS Question

Hide UISearchBar clear text button

I would like to know how to hide or not display the

cross that appears in the
fo the

I have tried using this

filterSearchBar.showsCancelButton = NO;

however this is an acutal cancel button not the small grey cross, so I would like to know if there is an equivilant for the small grey button that shows in the

any help would be appreciated.

Answer Source

You need to get the textField of the Search Bar:

UITextField *textField = [searchBar valueForKey:@"_searchField"];
textField.clearButtonMode = UITextFieldViewModeNever;

hope this help! =)