//每个Item宽高
CGFloat W = ;
CGFloat H = ;
//每行列数
NSInteger rank = ;
//每列间距
CGFloat rankMargin = (self.view.frame.size.width - rank * W) / (rank - );
//每行间距
CGFloat rowMargin = ;
//Item索引 ->根据需求改变索引
NSUInteger index = ; for (int i = ; i< index; i++) {
//Item X轴
CGFloat X = (i % rank) * (W + rankMargin);
//Item Y轴
NSUInteger Y = (i / rank) * (H +rowMargin);
//Item top
CGFloat top = ;
UIView *speedView = [[UIView alloc] init];
speedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"taozi"]];
speedView.frame = CGRectMake(X, Y+top, W, H);
[self.view addSubview:speedView];
}