美文网首页
一堆小标签点其他变成单选点击别的多选

一堆小标签点其他变成单选点击别的多选

作者: ljzza | 来源:发表于2018-03-28 13:49 被阅读0次
    //点击选择标签
    -(void)titleChooseChangeContentAction:(UIButton *)button
    {
        NSArray *array = [NSArray arrayWithObjects:@"潮玩",@"旅游",@"骑行",@"演唱会",@"电竞",@"越野",@"厨艺赛",@"运动",@"漂流",@"其他", nil];
        if ([button.titleLabel.text isEqualToString:@"其他"]) {
            for (int i = 0; i < array.count; i++) {
                UIButton *abutton = [self.view viewWithTag:100 + i];
                abutton.selected = NO;
                abutton.layer.borderColor = colorWithLightGray.CGColor;
            }
            button.selected = !button.selected;
            if (button.selected == YES) {
                button.layer.borderColor = colorWithMainColor.CGColor;
            }
            else
            {
                button.layer.borderColor = colorWithLightGray.CGColor;
            }
            
        }else
        {
            for (int i = 0; i < array.count; i++) {
                UIButton *abutton = [self.view viewWithTag:100 + i];
                if ([abutton.titleLabel.text isEqualToString:@"其他"]) {
                    abutton.selected = NO;
                    abutton.layer.borderColor = colorWithLightGray.CGColor;
                }
            }
            button.selected = !button.selected;
            if (button.selected == YES) {
                button.layer.borderColor = colorWithMainColor.CGColor;
            }
            else
            {
                button.layer.borderColor = colorWithLightGray.CGColor;
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:一堆小标签点其他变成单选点击别的多选

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