您的位置:首页 > 其它

记录笔记-关于CollectionView的表头表尾的配置

2016-09-13 13:57 351 查看
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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: