IOS开发for循环创建button
2016-03-25 20:30
477 查看
for循环创建button
for (int i = 0; i < 9; i++) { int a = i/4; //取余 int b = i%4; //取整 UIButton *tagButton = [[UIButton alloc] initWithFrame:CGRectMake(20+(10+(kScreenWidth-6)/5)*b, 90+(20+10)*a, (kScreenWidth-6)/5, 20)]; tagButton.layer.borderColor = MyHexColor(@"ee2266").CGColor; tagButton.layer.borderWidth = 1; tagButton.layer.cornerRadius = 5; tagButton.tag = i; tagButton.titleLabel.font = [UIFont systemFontOfSize:12]; [tagButton setTitle:_buttonArray[i] forState:UIControlStateNormal]; [tagButton setTitleColor:MyHexColor(@"ee2266") forState:UIControlStateNormal]; [tagButton addTarget:self action:@selector(tagButtonAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:tagButton]; }
相关文章推荐
- iOS:手把手教你发布代码到CocoaPods(Trunk方式)
- 关于iOS工程文件夹的布局框架.
- 获取iOS设备的信息
- ios an ssl error has occurred and a secure
- IOS开发之结构体的使用
- IOS开发之storyBoard以及xib的使用
- iOS-百度地图添加标注自定义气泡
- 浅谈iOS运行时机制runtime(1)
- iOS 时间分钟秒的倒计时
- 【iOS】银联支付
- IOS-58-阶段性小细节汇总
- iOS 邮箱判断
- ios延迟的几种方式
- Nagios监控ESXI主机系统、硬件、nagios日志文件时间格式转换
- iOS学习之路(二)--基础篇
- Html5嵌入app后通过JS和ios以及android客户端交互
- iOS存储数据字典到沙盒
- iOS自适应布局之Masonry(一)
- ios address book 操作大全
- iOS开发如何实现版本更新