// 1.创建流水布局 UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; // 2.设置每个格子的尺寸 layout.itemSize = CGSizeMake(250, 250); // 3.设置整个collectionView的内边距 CGFloat paddingY = 20; CGFloat paddingX = 40; layout.sectionInset = UIEdgeInsetsMake(paddingY, paddingX, paddingY, paddingX); // 4.设置每一行之间的间距 layout.minimumLineSpacing = paddingY;