美文网首页
UICollectionView 设置headView

UICollectionView 设置headView

作者: Bonucci | 来源:发表于2017-03-23 12:05 被阅读0次

从 UICollectionReusableView 继承。

@interface HeaderCRView : UICollectionReusableView

然后在Vc里面通过registerClass把该类注册进去

 [self.collectionView registerClass:[HeaderCRView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kheaderIdentifier];

当然这个设置不能忘记

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
    CGSize size={320,45};
    return size;
}

相关文章

网友评论

      本文标题:UICollectionView 设置headView

      本文链接:https://www.haomeiwen.com/subject/uruznttx.html