首页 > 移动平台 > 详细

IOS 多行多列加载ImageView

时间:2015-09-21 01:29:12      阅读:371      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!