开发者社区> 问答> 正文

UICollectionView HeaderView 怎么做

如题。我希望UICollectionView中实现类似于UITableView的tableHeaderView,怎么做啊

展开
收起
a123456678 2016-07-28 14:13:37 2330 0
1 条回答
写回答
取消 提交回答
  • 在初始化时和添加cell类似
    [collectionView registerClass:[HeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeadID];
    再加楼上的

    • (UICollectionReusableView )collectionView:(UICollectionView )collectionView viewForSupplementaryElementOfKind:(NSString )kind atIndexPath:(NSIndexPath )indexPath
      {

    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
    HeadView * view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:HeadID forIndexPath:indexPath];
    return view;
    }
    return nil;
    }

    2019-07-17 20:01:23
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载