iOS|iOS - 设置UISearchBar不是第一响应者时取消按钮依旧可以点击(2016-07-01)

#pragma mark - 遍历改变搜索框 取消按钮的文字颜色(取消时取消按钮依旧可以点击) - (void)changeSearchBarCancelBtnTitleColor:(UIView *)view {if (view) {if ([view isKindOfClass:[UIButton class]]) {UIButton *getBtn = (UIButton *)view; [getBtn setEnabled:YES]; //设置可用[getBtn setUserInteractionEnabled:YES]; //设置取消按钮字体的颜色“#0374f2”[getBtn setTitleColor:COLOR_STYLE forState:UIControlStateReserved]; [getBtn setTitleColor:COLOR_STYLE forState:UIControlStateDisabled]; return; }else{for (UIView *subView in view.subviews) {[self changeSearchBarCancelBtnTitleColor:subView]; }}}else{return; }}#pragma mark end

    推荐阅读