DWCollectionView 2.0.3.3

DWCollectionView 2.0.3.3

DawnWdf维护。



  • Dawn

DWCollectionView

详细说明文档可在以下位置查阅:http://www.jianshu.com/p/b8b99a688d6a

支持Carthage安装 github "DawnWdf/DWCollectionView",支持CocoaPods安装 pod "DWCollectionView"。

这是一个对UICollectionView的简单封装,当我们在使用多种Cell类型的CollectionView时,基本上都是在各个代理类中进行多个if-else处理。这个类通过转换代理对象的方式,将常用的代理方法分离出来,使得在注册cell、header、footer时可以将代码放在同一个区域内统一管理,提高代码可读性。使用方法如下:

[self.collectionView registerViewAndModel:^(DWCollectionDelegateMaker *maker) {

maker.registerCell([TeamInfoCell class],[TeamInfo class])
.itemSize(^(NSIndexPath *indexPath, id data){
    return CGSizeMake(150, 150);
})
.adapter(^(UICollectionViewCell *cell, NSIndexPath *indexPath, id data){
    TeamInfoCell *newCell = (TeamInfoCell *)cell;
    [newCell bindData:data];
});


maker.registerHeader([LeagueHeaderReusableView class],[LeagueInfo class])
.sizeConfiger(^ CGSize (UICollectionViewLayout *layout , NSInteger section, id data){
    return CGSizeMake(300, height_header);
})
.adapter(^(UICollectionReusableView *reusableView,NSIndexPath *indexPath, id data){
    LeagueHeaderReusableView *header = (LeagueHeaderReusableView *)reusableView;
    [header bindData:data];
});
}];