@chenbinghua
2018-05-04T09:58:44.000000Z
字数 668
阅读 1117
iOS笔记
怎样在UICollectionView中添加Header和footer
UICollectionView必须制定一个UICollectionViewFlowLayout
UICollectionViewController代码- (instancetype)init{// 流水布局对象,设置cell的尺寸和位置UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];// 每行cell的个数NSInteger colNums = 3;// 统一的间距CGFloat spacing = 5;// cell的宽度CGFloat cellW = (BBScreenW - (colNums + 1) * spacing) / colNums;// cell的高度CGFloat cellH = 180;// 设置cell的尺寸layout.itemSize = CGSizeMake(cellW, cellH);// 设置cell之间间距layout.minimumInteritemSpacing = spacing;// 设置行距layout.minimumLineSpacing = spacing;// 设置每一组的内间距layout.sectionInset = UIEdgeInsetsMake(spacing, spacing, spacing, spacing);return [super initWithCollectionViewLayout:layout];}
