iOS Change the title of cancel button in UISearchBar

前端 未结 13 1804
隐瞒了意图╮
隐瞒了意图╮ 2020-12-28 10:35

I wish to change the title of the cancel button in iOS. I have been using this previously:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayCon         


        
相关标签:
13条回答
  • 2020-12-28 11:13

    Before search started, in UISearchBarDelagate or UISearchDisplayControllerDelegate do:

    [self.searchDisplayController.searchBar.subviews enumerateObjectsUsingBlock:^(UIButton *subview, NSUInteger idx, BOOL *stop) {
                if ([subview isKindOfClass:[UIButton class]]) {
                    [subview setTitle:@"OK" forState:UIControlStateNormal];
                    *stop = YES;
                }
            }];
    
    0 讨论(0)
提交回复
热议问题