9.13 创建不等的按钮(第一行4个,第二行3个)
2017-07-13 本文已影响0人
小码农杰哥
CGFloat btnW = SIZE.width/4;
for (NSInteger i=0; i<7; i++) {//7个按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake((i%4)*btnW, (i/4)*btnW, btnW, btnW);
[btn setTitle:@"纷纷" forState:UIControlStateNormal];
btn.backgroundColor = [UIColor cyanColor];
[self.view addSubview:btn];
}