bottemLayout = [[UICollectionViewFlowLayout alloc]init];
// 垂直滚动(默认)
bottemLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
bottemLayout.itemSize = CGSizeMake(DeviceWidth/2,GoodCell_Height);
//item的列间距
bottemLayout.minimumInteritemSpacing = 0;
//item的行间距
bottemLayout.minimumLineSpacing = 0 ;
bottemLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
bottemLayout.headerReferenceSize = CGSizeMake(0,BannerHeight + menuCount_Row * MenuHeight_Row+50 + 50 + MiaoPaiList_Height+MiaoPaiSingle_Height +ThreeHeight_Height +50 + 15);
bottemLayout.footerReferenceSize = CGSizeMake(0 , 0);
goodsListCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0 , DeviceWidth, DeviceHeight - 64) collectionViewLayout:bottemLayout];
goodsListCollectionView.backgroundColor =[UIColor clearColor];
goodsListCollectionView.delegate =self;
goodsListCollectionView.dataSource = self;
goodsListCollectionView.showsVerticalScrollIndicator =NO;
goodsListCollectionView.showsHorizontalScrollIndicator = NO;
[self.view addSubview:goodsListCollectionView];
[goodsListCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"goods"];
[goodsListCollectionView registerClass:[CustomCollectionHeader class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"myhead"];
-(UICollectionReusableView*)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
CustomCollectionHeader * headerView =[goodsListCollectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"myhead" forIndexPath:indexPath];
headerView.layer.masksToBounds = YES;
[headerView initModelWith_height:BannerHeight + menuCount_Row * MenuHeight_Row+50 + 50 + MiaoPaiList_Height+MiaoPaiSingle_Height +ThreeHeight_Height +50 + 15 WithModelDic:nil];
return headerView;
}
关于 collection 头视图 尾视图 设置
最新推荐文章于 2024-10-10 12:48:17 发布
本文介绍如何使用UICollectionViewFlowLayout进行 UICollectionView 的布局配置,包括设置垂直滚动方向、item尺寸、间距及边距等参数,并展示了如何注册单元格和头部视图。
1748

被折叠的 条评论
为什么被折叠?



