UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(130, 130);
layout.footerReferenceSize = CGSizeMake(300, 20);
layout.headerReferenceSize = CGSizeMake(300, 40);
///设置区的内边距
layout.sectionInset = UIEdgeInsetsMake(10, 0, 50, 0);
UICollectionView *v = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 10, 300, 500) collectionViewLayout:layout];
[v registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"kkk"];
[v registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footer"];
[v registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
v.delegate = self;
v.dataSource = self;
[self.view addSubview:v]
展示的效果如图,其中 layout.sectionInset = UIEdgeInsetsMake(10, 0, 50, 0);
表明我们设置的sectioninset,设置的是每个区内的区头和区尾到本区的CELL之间的距离,,并不是区头到上一个区尾的距离
;