美文网首页
9.13 创建不等的按钮(第一行4个,第二行3个)

9.13 创建不等的按钮(第一行4个,第二行3个)

作者: 小码农杰哥 | 来源:发表于2017-07-13 23:14 被阅读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];

}

相关文章

网友评论

      本文标题:9.13 创建不等的按钮(第一行4个,第二行3个)

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