集合视图的头部视图

-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
注册

[self.collectionView registerClass:[ToolHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:ToolHeaderViewIdentifier];

{
UICollectionReusableView *reusableView =nil;

if (kind == UICollectionElementKindSectionHeader) {
    //定制头部视图的内容
    ToolHeaderView *headerV = [ToolHeaderView returnResueCellFormTableView:self.collectionView indexPath:indexPath identifier:ToolHeaderViewIdentifier];
    headerV.titleLb.text = [NSString stringWithFormat:@"热卖品类 %ld", (long)indexPath.section];
    headerV.titleFont = [UIFont systemFontOfSize:14];
    headerV.titleTextColor = [UIColor redColor];
    headerV.headerViewBgColor = [UIColor whiteColor];
    
    reusableView = headerV;
} else if (kind == UICollectionElementKindSectionFooter) {
    GoodsReclassFootView *footView = [GoodsReclassFootView returnResueCellFormTableView:self.collectionView indexPath:indexPath identifier:GoodsReclassFootViewIdentifier];
    footView.backgroundColor = BackCellColor;
    reusableView = footView;
}

return reusableView;

}

你可能感兴趣的:(集合视图的头部视图)