Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide UISearchBar clear text button

I would like to know how to hide or not display the UISearchBar cross that appears in the textField fo the UISearchBar

I have tried using this

filterSearchBar.showsCancelButton = NO;

However this is an actual cancel button not the small grey cross, so I would like to know if there is an equivalent for the small grey button that shows in the UISearchBar.

like image 400
HurkNburkS Avatar asked Feb 03 '14 07:02

HurkNburkS


1 Answers

You need to get the textField of the Search Bar:

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

hope this help! =)

like image 199
Soto_iGhost Avatar answered Oct 22 '22 16:10

Soto_iGhost