#define kViewW 40 //宽度 #define kViewH 61 //高度 #define kColCount 4 //共几列 CGFloat marginX = (self.view.bounds.size.width - kColCount * kViewW) / (kColCount + 1); CGFloat marginY = 0.5; for (int i = 0; i < self.payList.count; i++) { int row = i / kColCount; int col = i % kColCount; CGFloat x = marginX + col * (marginX + kViewW); CGFloat y = marginY + row * (marginY + kViewH); PayInfoView *payView = [PayInfoView payViewWithInfo:self.payList[i]]; payView.delegate = self; payView.frame = CGRectMake(x, y, kViewW, kViewH); [self.view addSubview:payView]; }