iOS 如何修改searchBar的取消按钮的文字

方法一:

[searchBar setValue:@"取消"forKey:@"_cancelButtonText"];

方法二 :

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitle:@"取消"];

方法三:

for (id cencelButton in [searchBar.subviews[0] subviews])
    {
        if([cencelButton isKindOfClass:[UIButton class]])
        {
            UIButton *btn = (UIButton *)cencelButton;
            [btn setTitle:@"取消"  forState:UIControlStateNormal];
        }
    }

你可能感兴趣的:(iOS 如何修改searchBar的取消按钮的文字)