UICollectionReusableView 头视图注册

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

{

UICollectionReusableView *reusableview = nil;

if (kind == UICollectionElementKindSectionHeader){

RecipeCollectionHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];

NSString *title = [[NSString alloc] initWithFormat:@"Recipe Group #%i",indexPath.section +1];

headerView.title.text = title;

UIImage *headerImage = [UIImage imageNamed:@"header_banner.png"];

headerView.backgroundImage.image = headerImage;

reusableView = headerView;

}

if (kind == UICollectionElementKindSectionFooter){

UICollectionReusableView *footerview = [collectionView dequeueResuableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView" forIndexPath:indexPath];

reusableview = footerview;

}

return reusableview;

}

你可能感兴趣的:(UICollectionReusableView 头视图注册)