// 每个item宽高
CGFloat W = 90;
CGFloat H = 110;
// 每行列数
NSInteger rank = 4;
// 每列间距
CGFloat rankMargin = (self.view.frame.size.width-rank *W)/(rank-1);
// 每行间距
CGFloat rowMargin = 30;
// item索引-->根据需求改变索引
NSUInteger index = 9;
for (int i=0; i<index; i++) {
// Item X轴
CGFloat X = (i%rank)*(W+rankMargin);
CGFloat Y = (i/rank)*(H+rowMargin);
// Item top
CGFloat top = 50;
UIImageView *imageV = [[UIImageView alloc]init];
imageV.image = [UIImage imageNamed:@"IMG_1170 2"];
imageV.frame = CGRectMake(X, Y+top, W, H);
[self.view addSubview:imageV];
}
}