29、UISearchController 的 cancel 按钮设置

//----
searchController.delegate = self;

// --searchbar的代理方法
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
    // --取消按钮
    searchBar.showsCancelButton = YES;
    UIButton *btn = [searchBar valueForKey:@"_cancelButton"];
    [btn setTitle:@"取消" forState:UIControlStateNormal];
    return YES;
}

你可能感兴趣的:(29、UISearchController 的 cancel 按钮设置)