正文
类、协议
|
功能
|
YHCollectionViewCellModel、YHCollectionViewSectionModel
|
表征 cell、 section header 和 section footer 相关数据的 view model
|
YHCollectionViewAdapter
|
包装 UICollectionView 代理方法的核心类,将代理回调形式的接口转换成 view model 形式的数据驱动接口
|
YHCollectionViewCell、YHCollectionViewSectionHeaderFooter
|
定义 cell 和 section header、footer 的通用接口,用来绑定 view model 数据,以及获取高度
|
MessageInterceptor
|
处理消息转发的拦截器
|
使用方法
1. 创建 collection view:
self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds
collectionViewLayout:self.collectionViewLayout]; // 这里也可以使用自己的 layout
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.collectionView.backgroundColor = [UIColor colorWithRed:244 green:244 blue:244 alpha:1.0];
self.collectionView.alwaysBounceVertical = YES;
[self.view addSubview:self.collectionView];
2. 创建
YHCollectionViewAdapter
,绑定 collectionView,设置代理:
self.adapter = [[YHCollectionViewAdapter alloc] init];