测试MarkDown

作者: 提笔挥墨 | 来源:发表于2021-08-16 15:23 被阅读0次

UICollectionView headerView 重用

1、必须注册并且签署delegate

1.1 3个代理
<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView"];

2、设置头视图大小

self.flow.headerReferenceSize = CGSizeMake(WIDTH, 60);

3、实现UICollectionViewDelegateFlowLayout 代理方法

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    UICollectionReusableView *headerView = nil;
    if (kind == UICollectionElementKindSectionHeader) {
        headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"headerView" forIndexPath:indexPath];
        // 避免重复添加
        if (headerView.subviews.count == 0) {
            headerView.backgroundColor = [UIColor redColor];
            UILabel *lab = [[UILabel alloc] init];
            [headerView addSubview:lab];
            lab.textColor = [UIColor blackColor];
            NSArray *arr = self.datas[indexPath.section];
            lab.backgroundColor = CLEAR_COLOR;
            lab.tag = 100;
            lab.text = arr[0];
            [lab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
        }

        UILabel *lab = [headerView viewWithTag:100];
        NSArray *arr = self.datas[indexPath.section];
        lab.text = arr[0];


    }
    return headerView;
}

相关文章

  • markdown测试

    markdown测试 markdown测试 markdown测试 markdown测试 public static...

  • 2021-01-26 测试

    Markdown测试 Markdown测试

  • 第一篇

    第一篇 测试markdown markdown测试

  • 无标题文章

    markdown 语言测试 **markdown** *mark* ##markdown #markdown ma...

  • markdown测试

    markdown测试 测试

  • 2018-09-04

    1.markdown 代码块测试 看了下markdown的语法格式,测试

  • 2017-12-29

    *** 测试Markdown 基本语法 #测试1 #测试2

  • demo 测试

    *** 一条横线 demo 测试 测试 markdown 语法 markdown 常用语法 # 标题 * +...

  • 阿里云文件处理

    ## 测试markdown

  • #

    #测试 ##markdown

网友评论

    本文标题:测试MarkDown

    本文链接:https://www.haomeiwen.com/subject/hgrajttx.html