UISearchController和UISearchBar的Cancle按钮改title问题,简单粗暴

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar

{

searchController.searchBar.showsCancelButton = YES;

UIButton *canceLBtn = [searchController.searchBar valueForKey:@"cancelButton"];

[canceLBtn setTitle:@"取消" forState:UIControlStateNormal];

[canceLBtn setTitleColor:[UIColor colorWithRed:14.0/255.0 green:180.0/255.0 blue:0.0/255.0 alpha:1.00] forState:UIControlStateNormal];

searchBar.showsCancelButton = YES;

return YES;

}

推荐阅读更多精彩内容