zoukankan      html  css  js  c++  java
  • iOS中UICollectionView添加头视图

    参考链接:https://www.jianshu.com/p/ef57199bf34a

    找了一堆的博客,写的都少了很重要的一步。

    //引入头部视图
    -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
    {
        UICollectionReusableView *reusableview = nil;
        NSLog(@"kind = %@", kind);
        if (kind == UICollectionElementKindSectionHeader){
            
            CouponCollHeaderView *headerV = (CouponCollHeaderView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:CellHeadID forIndexPath:indexPath];
            headerV.backgroundColor = [UIColor greenColor];
            [headerV getSHCollectionReusableViewHearderTitle:@"这是标题"];
            reusableview = headerV;
        }
        
        return reusableview;
        
    }
    //设置头部高度
    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
        
        return CGSizeMake(SCREEN_WIDTH, CONVER_VALUE(245.5f));
    }

    剩下的后期整理。

  • 相关阅读:
    2021/3/16
    2021/3/15
    plist
    百度小程序更新管理
    uni-app v-for v-modal
    小程序中不能使用字符串模板吗
    条件编译
    百度app 和小程序版本关系
    uni-app 全局变量的几种实现方式
    canvas 换行处理
  • 原文地址:https://www.cnblogs.com/liuzhi20101016/p/11909040.html
Copyright © 2011-2022 走看看