码迷,mamicode.com
首页 > 其他好文 > 详细

九宫格布局

时间:2015-12-14 18:53:06      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:

//
//  九宫格布局.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];
        
        
    }
    
}

九宫格布局

标签:

原文地址:http://www.cnblogs.com/er-dai-ma-nong/p/5045687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!