美文网首页
RadioBox(单选)

RadioBox(单选)

作者: 碧海云天V | 来源:发表于2018-02-05 11:25 被阅读204次

    先上Demo

    有些筛选项中会用到单选,我就想办法封装了一个RadioBox。
    DingTalk20180205112113.png

    调用代码部分

    #import "ViewController.h"
    #import "RadioBoxFun.h"//引入的头文件
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        RadioBoxFun *radioBox = [RadioBoxFun new];
        UIButton *btn0 =  [radioBox creatButton:CGRectMake(16, 40, (WIDTH-50-32)/3-5, 22) title:@"不限"];
        UIButton *btn1 =  [radioBox creatButton:CGRectMake((WIDTH-50-32)/3+16, 40, (WIDTH-50-32)/3-5, 22) title:@"已签约"];
        UIButton *btn2 =  [radioBox creatButton:CGRectMake((WIDTH-50-32)/3*2+16, 40, (WIDTH-50-32)/3-5, 22) title:@"已注册"];
        UIButton *btn3 =  [radioBox creatButton:CGRectMake(16, 40+22+10, (WIDTH-50-32)/3-5, 22) title:@"待联系"];
        UIButton *btn4 =  [radioBox creatButton:CGRectMake((WIDTH-50-32)/3+16, 40+22+10, (WIDTH-50-32)/3-5, 22) title:@"无效"];
        [radioBox radioBoxButtons:@[btn0,btn1,btn2,btn3,btn4]  superView:self.view defultSelectedInde:0 callBack:^(NSInteger selectIndex, NSString *title) {
            NSLog(@"%ld-----%@",(long)selectIndex,title);
        }];
    
    }
    
    具体的请参照Demo上的代码

    相关文章

      网友评论

          本文标题:RadioBox(单选)

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