测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2014年12月 |
由 Peter Meyers 维护。
依赖 | |
PMUtils | >= 0 |
PMCircularCollectionView | >= 0 |
PMBrowsingCollectionView 是 UICollectionView 的子类,通过引入展开和折叠段的概念,实现了一种新的交互,便于浏览一系列单元格。
为了安装,只需将以下行添加到您的 Podfile 中。
platform :ios, '7.0'
pod "PMBrowsingCollectionView"
要查看 PMBrowsingCollectionView 的实际应用,请运行位于 /Example/PMBrowsingCollectionView-iOSExample.xcworkspace 的示例项目。在安装 PMBrowsingCollectionView pod 后,将其整合到项目中的方式与创建典型的 UICollectionView 相似。
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
layout.minimumInteritemSpacing = 2.0f;
layout.minimumLineSpacing = 2.0f;
PMBrowsingCollectionView *collectionView = [PMBrowsingCollectionView collectionViewWithFrame:self.view.bounds
collectionViewLayout:layout];
collectionView.delegate = self;
collectionView.dataSource = self;
[collectionView registerClass:[UICollectionViewCell class]
forCellWithReuseIdentifier:@"cellReuseIdentifier"];
[collectionView registerClass:[UICollectionReusableView class]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"headerReuseIdentifier"];
[self.view addSubview:collectionView];
- (UICollectionViewCell *)collectionView:(PMBrowsingCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellReuseIdentifier" forIndexPath:indexPath];
NSUInteger normalizedIndex = [collectionView normalizeItemIndex:indexPath.item forSection:indexPath.section];
/*
* Configure cell based on indexPath.section and normalizedIndex
*/
return cell;
}
PMBrowsingCollectionViewDelegate 为 UICollectionViewDelegateFlowLayout 添加了三个可选方法
- (CGFloat) collectionView:(PMBrowsingCollectionView *)collectionView shadowRadiusForSection:(NSInteger)section
{
return 20.0f;
}
- (UIColor *) collectionView:(PMBrowsingCollectionView *)collectionView shadowColorForSection:(NSInteger)section
{
return [UIColor blackColor];
}
// Only called when section is in a collapsed state.
- (void) collectionView:(PMBrowsingCollectionView *)collectionView willCenterItemAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger normalizedIndex = [collectionView normalizeIndex:indexPath.item];
DLog(@"Will center cell at section index %d, item index %d", indexPath.section, normalizedIndex);
}
PMBrowsingCollectionView 可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。