Wissam iOS Wissam iOS - 1 year ago 112
iOS Question

UISearchController change 'Cancel' button title

How we can change the title of cancel button in search controller?

enter image description here

Answer Source

You can change the "Cancel" Button in search bar using this-

for (UIView *view in searchBar.subviews)
    for (id subview in view.subviews)
        if ( [subview isKindOfClass:[UIButton class]] )
            [subview setEnabled:YES];
            UIButton *cancelButton = (UIButton*)subview;
            [cancelButton setTitle:@"hi" forState:UIControlStateNormal];

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download