码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 多行多列加载ImageView

时间:2015-09-21 01:32:21      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

用宏定义行高,行宽,行数,列数及间隔

#define ROW_COUNT  5

#define COLUMN_COUNT 3

#define ROW_HEIGHT 100

#define ROW_WIDTH ROW_HEIGHT

#define CELL_SPACING 10

 

 

 

- (void)viewDidLoad {

    [super viewDidLoad];

    [self layoutUI];

 

}

-(void)layoutUI{

  _imageViews = [NSMutableArray array];

    //5行3列图片数据放到可变数组中

    for (int r=0; r<ROW_COUNT; r++) {

        for (int c=0; c<COLUMN_COUNT; c++) {

            UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(c*ROW_WIDTH+(c*CELL_SPACING), r*ROW_HEIGHT+(r*CELL_SPACING                           ), ROW_WIDTH, ROW_HEIGHT)];

            imageView.contentMode=UIViewContentModeScaleAspectFit;

            [self.view addSubview:imageView];

            [_imageViews addObject:imageView];

            

        }

    }

 

 

 

    }

IOS 多行多列加载ImageView

标签:

原文地址:http://www.cnblogs.com/yuyu-2012/p/4824821.html

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