有些筛选项中会用到单选,我就想办法封装了一个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上的代码
网友评论