您的位置:首页 > 其它

九宫格布局

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];

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: