1.注册UICollectionView以及类似于tableView的组头之类的东西
http://www.cnblogs.com/wayne23/p/4013522.html
[_collectionView registerNib:[UINib nibWithNibName:@"BBSCell" bundle:nil] forCellWithReuseIdentifier:@"BBSCell"];
BBSSectionHeaderView ->(继承自)UICollectionReusableView
[_collectionView registerClass:[BBSSectionHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
//组头的大小
layout.headerReferenceSize = CGSizeMake(ScreenSize.width, 40);
//协议中的用法
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
UICollectionReusableView *resableView = nil;
if (kind == UICollectionElementKindSectionHeader) {
BBSSectionHeaderView *headerView = (BBSSectionHeaderView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenSize.width, 40)];
label.text = _bbsSectionNameArr[indexPath.section];
label.font = [UIFont systemFontOfSize:17];
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor whiteColor];
[headerView addSubview:label];
resableView = headerView;
}
return resableView;
}