本来是想找个简单的方法来多个按键单选,结果网上找的都写了一堆,明明三行代码能搞定的事儿- -,先上干货各位看官看一下吧:(pScreenWidth屏幕宽度)
#define WidthLine (pScreenWidth )/3
@property (strong,nonatomic)UIButton *choseBtn;
多个按键布局:
NSArray * nameAry = [NSArray arrayWithObjects:@" 垃圾营销",@" 涉黄信息",@" 不实消息",@" 人身攻击",@" 有害信息",@" 内容抄袭",@" 违法信息",@" 恶意营销",@" 诈骗信息", nil];
for (int i = 0; i< 3; i++) {
for (int j = 0; j < 3; j++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom ];
[btn setTitle:[NSString stringWithFormat:@"%@",nameAry[i*3 +j]] forState:UIControlStateNormal];
[btn setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] forState: