把UISearchController的cancel按钮自定义
2017-04-05 本文已影响0人
H了M
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController{
searchController.searchBar.showsCancelButton = YES;
for(id cc in [searchController.searchBar.subviews[0] subviews])
{
if([cc isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)cc;
[btn setTitle:@"取消" forState:UIControlStateNormal];
}
}
}
或者是。[_searchVC.searchBar setValue:@"取消" forKey:@"_cancelButtonText"];