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

2018-03-28  本文已影响0人  ljzza
//点击选择标签
-(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;
        }
    }
}
上一篇下一篇

猜你喜欢

热点阅读