九宫格布局
2015-12-14 16:33
288 查看
//
// 九宫格布局.h
// IOS笔记
-(void)createUI{
NSArray *titles = @[@"我的设置",@"我的关注",@"我的账户",@"我的收藏",@"我的下载",@"我的评论",@"我的帮助",@"我的应用"];
NSArray *images = @[@"setting",@"favorite",@"user",@"collect",@"download",@"comment",@"help",@"candou"];
for (int i=0; i<titles.count; i++) {
CGFloat buttonW = (KscreenRect.size.width-30*4)/3.0;
int H=i/3;
int L=i%3;
CGFloat butonX = (buttonW +30)*L+30;
CGFloat butonY = (buttonW +30)*H+64+30;
WQDButton *button = [WQDButton addButtonWithFrame:CGRectMake(butonX, butonY, buttonW, buttonW) title:nil andBlock:^{
if (3==i) {
// CollectionViewController *collection = [[CollectionViewController alloc]init];
// [self.navigationController pushViewController:collection animated:YES];
}
}];
[button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"account_%@",images[i]]] forState:UIControlStateNormal];
[self.view addSubview:button];
// UILabel *label = [UILabel labelWithFrame:CGRectMake(butonX, butonY+buttonW, buttonW, 30) andtitle:titles[i]];
//
// label.font =[UIFont systemFontOfSize:9];
// label.textAlignment=NSTextAlignmentCenter;
// [self.view addSubview:label];
}
}
// 九宫格布局.h
// IOS笔记
-(void)createUI{
NSArray *titles = @[@"我的设置",@"我的关注",@"我的账户",@"我的收藏",@"我的下载",@"我的评论",@"我的帮助",@"我的应用"];
NSArray *images = @[@"setting",@"favorite",@"user",@"collect",@"download",@"comment",@"help",@"candou"];
for (int i=0; i<titles.count; i++) {
CGFloat buttonW = (KscreenRect.size.width-30*4)/3.0;
int H=i/3;
int L=i%3;
CGFloat butonX = (buttonW +30)*L+30;
CGFloat butonY = (buttonW +30)*H+64+30;
WQDButton *button = [WQDButton addButtonWithFrame:CGRectMake(butonX, butonY, buttonW, buttonW) title:nil andBlock:^{
if (3==i) {
// CollectionViewController *collection = [[CollectionViewController alloc]init];
// [self.navigationController pushViewController:collection animated:YES];
}
}];
[button setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"account_%@",images[i]]] forState:UIControlStateNormal];
[self.view addSubview:button];
// UILabel *label = [UILabel labelWithFrame:CGRectMake(butonX, butonY+buttonW, buttonW, 30) andtitle:titles[i]];
//
// label.font =[UIFont systemFontOfSize:9];
// label.textAlignment=NSTextAlignmentCenter;
// [self.view addSubview:label];
}
}
相关文章推荐
- jsp获取当前日期
- BZOJ1798: [Ahoi2009]Seq 维护序列seq
- iOS_带下划线的Label
- 第十六周 项目一 (1) 显示直接插入排序过程
- 第十六周 项目一 验证算法(4)快速排序
- 欢迎使用CSDN-markdown编辑器
- 第六周 项目四 数质转换
- (转)位运算及其应用详解
- deb和rpm文件安装
- AngularJS 05
- OpenCV笔记(五)
- Spark Streaming与Storm的对比分析
- ADB(Android Debug Bridge) 的使用
- 浅谈压缩感知(二):理论基础
- 浅谈压缩感知(一):背景简介
- linux硬件访问技术
- 去掉字符串中的html标签的方法
- iOS9适配中的各种问题
- 准生证
- 模式识别之聚类---聚类和分类的区别