Latest 1.0.0
Homepage https://github.com/yangshebing/BGCollectionView
License MIT
Platforms ios 6.0, requires ARC
Dependencies BGUIFoundationKit, SDWebImage
Authors

BGCollectionView是基于UICollectionView(纯代码方式)实现上下拉刷新加载数据的瀑布流式(WaterFlow)布局,
其中集成下拉刷新采用的是EGORefreshTableHeaderView。

环境要求

  • iOS6.0+
  • Xcod7.0+

安装方法

CocoaPods安装方式:

pod "BGCollectionView"

手动安装方式:

导入"WaterFlow"与"EGOTableViewPullRefresh"文件夹至目标工程中。

使用方法

(1)创建自定义瀑布流式布局

    BGCollectionViewFlowLayout *waterFlowLayout = [[BGCollectionViewFlowLayout alloc] init];
    waterFlowLayout.delegate = self;
    //设置列数
    waterFlowLayout.columnNum = 4;
    //设置列间距
    waterFlowLayout.minimumInteritemSpacing = 15;
    //设置行间距
    waterFlowLayout.minimumLineSpacing = 8;
    //设置头视图宽高,设置高度为0则不显示下拉刷新视图
    waterFlowLayout.headerReferenceSize = CGSizeMake(bScreenWidth, 0.1);
    //设置尾部视图宽高,设置高度为0则不显示上拉刷新视图
    waterFlowLayout.footerReferenceSize = CGSizeMake(bScreenWidth, 60);
    //设置上下左右间距
    waterFlowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);

(2)创建BGCollectionView

   BGCollectionView *waterFlowCollectionView = [[BGCollectionView alloc]initWithFrame:CGRectMake(0, 0, bScreenWidth, bScreenHeight - 64) collectionViewLayout:waterFlowLayout];
    waterFlowCollectionView.pullDownRefreshBlock = ^(UICollectionView *collectionView) {
        //下拉取最新数据
    };

    waterFlowCollectionView.pullUpRefreshBlock = ^(UICollectionView *collectionView) {
        //上拉取更多数据
    };
    [self.view addSubview:waterFlowCollectionView];

(3)实现BGCollectionViewFlowLayoutDelegate代理方法

- (CGFloat)collectionView:(UICollectionView *)collectionView
                   layout:(BGCollectionViewFlowLayout *)layout
 heightForItemAtIndexPath:(NSIndexPath *)indexPath
{
    //返回指定的高度
    return 100 + (rand() % 100);
}

协议许可

BGCollectionView遵循MIT许可协议。有关详细信息,请参阅许可协议。

Latest podspec

{
    "name": "BGCollectionView",
    "version": "1.0.0",
    "license": "MIT",
    "summary": "BGCollectionViewu662fu57fau4e8eUICollectionViewuff08u7eafu4ee3u7801u65b9u5f0fuff09u5b9eu73b0u4e0au4e0bu62c9u5237u65b0u52a0u8f7du6570u636eu7684u7011u5e03u6d41u5f0fuff08WaterFlowuff09u5e03u5c40",
    "homepage": "https://github.com/yangshebing/BGCollectionView",
    "authors": {
        "yangshebing": "[email protected]"
    },
    "source": {
        "git": "https://github.com/yangshebing/BGCollectionView.git",
        "tag": "1.0.0"
    },
    "source_files": "WaterFlow/*",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "dependencies": {
        "BGUIFoundationKit": [
            "~> 0.0.2"
        ],
        "SDWebImage": [
            "~> 3.7.3"
        ]
    }
}

Pin It on Pinterest

Share This