首页 > 其他 > 详细

第十三篇、OC_UICollectionView的基本配置

时间:2016-11-25 19:36:44      阅读:224      评论:0      收藏:0      [点我收藏+]
- (UICollectionView *) categoryCollectionView
{
    if (! _categoryCollectionView) {
        
        // 创建布局
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        layout.itemSize = CGSizeMake(KItemWidth,KItemHeight);
        layout.minimumInteritemSpacing = KSpace;
        layout.minimumLineSpacing = KSpace;
        layout.headerReferenceSize = CGSizeMake(KScreentW,KProductHeaderCellH);
        
        _categoryCollectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
        _categoryCollectionView.dataSource = self;
        _categoryCollectionView.delegate = self;
        _categoryCollectionView.backgroundColor = [UIColor colorWithRed:234.0/255 green:234.0/255 blue:234.0/255 alpha:1];
        
        // 注册
        [_categoryCollectionView registerNib:[UINib nibWithNibName:@"GFBCategoryCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:KProductCell];
        [_categoryCollectionView registerNib:[UINib nibWithNibName:@"GFBCategoryCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KProductHeaderCell];
        
        // 设置内边距,添加轮播图
        _categoryCollectionView.contentInset = UIEdgeInsetsMake(KBanerH, 0, 0, 0);

    }
    return _categoryCollectionView;
}

 

第十三篇、OC_UICollectionView的基本配置

原文:http://www.cnblogs.com/HJQ2016/p/6102538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!