本文以headerView为例。
实现效果如图:
首先学习一下这个类UICollectionReusableView
,这个类可以代表headerView和footerView。我们创建UICollectionReusableView
这个类的子类来自定义headerView和footerView。
如果要设置headerView和footerView,首先要注册:
[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:UID];
其中,Supplementary
翻译成”补充的,额外的”意思。
上面只注册了headerView,接着,实现 UICollectionViewDat