美文网首页
iOS - 设置UISearchBar不是第一响应者时取消按钮依

iOS - 设置UISearchBar不是第一响应者时取消按钮依

作者: 欧币杰昔 | 来源:发表于2016-07-01 16:27 被阅读296次
    #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

    相关文章

      网友评论

          本文标题:iOS - 设置UISearchBar不是第一响应者时取消按钮依

          本文链接:https://www.haomeiwen.com/subject/bdafjttx.html