码迷,mamicode.com
首页 > 移动开发 > 详细

ios 按钮单选框

时间:2015-10-21 16:08:15      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:

- (IBAction)btnChoose:(id)sender {

    _btnConfirm.selected =YES;

    UIImage *selecticonNo =[UIImage imageNamed:@"未选中"];

    UIImage *selecticon =[UIImage imageNamed:@"选中"];

    UIButton *btn=nil;

    for (int i=1;i<REPORTNUMBER;i++) {

        btn = (UIButton *)[self.view viewWithTag:i];   //获取单选按钮  mainZone 是最外层的视图

        if ([btn isSelected]) {

            [btn setBackgroundImage:selecticonNo forState:UIControlStateNormal];

            [btn setSelected:NO];

        }

    }

    

    [sender setBackgroundImage:selecticon forState:UIControlStateSelected];

      [sender setSelected:YES];

    UIButton *btnSelected = nil;

    btnSelected = sender;

    reportType = [NSString stringWithFormat:@"%d",(int) btnSelected.tag];

    

}

如果出现选中状态旁边有蓝色,需设置选中状态。tintcolor为白色

ios 按钮单选框

标签:

原文地址:http://my.oschina.net/u/2450398/blog/519836

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!