I would like to know how to hide or not display the UISearchBar
cross that appears in the textField
fo the UISearchBar
I have
Swift 5
Just add a single line below
searchBar.searchTextField.clearButtonMode = .never
You can remove the clear text button for all UISearchBar instances:
[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]].clearButtonMode = UITextFieldViewModeNever;
Converting Soto_iGhost's answer to Swift 4:
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
let textField: UITextField = searchBar.value(forKey: "_searchField") as! UITextField
textField.clearButtonMode = .never
}
If you have an outlet of UISearchBar
the you can write above code anywhere in your class.