UICollectionView的一些属性

本文介绍如何在UICollectionView中配置组头部视图,包括注册组头部视图类、设置组头大小及实现UICollectionViewDelegate补充视图的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.注册UICollectionView以及类似于tableView的组头之类的东西 

http://www.cnblogs.com/wayne23/p/4013522.html

 

[_collectionView registerNib:[UINib nibWithNibName:@"BBSCell" bundle:nilforCellWithReuseIdentifier:@"BBSCell"];

    

 

BBSSectionHeaderView ->(继承自)UICollectionReusableView

 

    [_collectionView registerClass:[BBSSectionHeaderView classforSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];

 

//组头的大小

layout.headerReferenceSize = CGSizeMake(ScreenSize.width40);

 

//协议中的用法

- (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 allocinitWithFrame:CGRectMake(00ScreenSize.width40)];

        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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值