MCCardPickerCollectionViewController 1.0.0

MCCardPickerCollectionViewController 1.0.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布最后发布2015年3月

Michael Chen维护。




一个受 Facebook "你可能认识的人" 启发的卡片集合视图控制器。

截图需要一点时间 :p
screen-shot

兼容性

需要 iOS 7。

使用方法

只需将位于 /src 文件夹下的类拖放到项目中,并像常规集合视图控制器一样使用。

要初始化 MCCardPickerCollectionViewController

MCCardPickerCollectionViewController *cardViewController = [[MCCardPickerCollectionViewController alloc] init];
    cardViewController.delegate = self;
    //Don't forget to register cell like usual collection view.
    [cardViewController.collectionView registerClass:[MCSampleCardCollectionViewCell class] forCellWithReuseIdentifier:kCellIdentifier];

并实现代理

- (void)cardPickerCollectionViewController:(MCCardPickerCollectionViewController *)cardPickerCollectionViewController preparePresentingView:(UIView *)presentingView fromSelectedCell:(UICollectionViewCell *)cell
{
    //Do whatever you want to prepare for the presenting view.
}

// and collection view delegate and data source

为了显示视图控制器,我们使用自己的方法而不是 presentViewController:animated:completion:,以保持透明背景。

- (void)presentInViewController:(UIViewController *)viewController;

要关闭视图控制器,同样地,我们使用自己的方法

- (void)dismissFromParentViewController;

此外,还有一些 MCCardPickerCollectionViewFlowLayout 的属性可以调整。如果您想更改卡片的填充,只需设置 minimumLineSpacing

cardViewController.layout.minimumLineSpacing = 40;

以及通过设置 flickVelocity 来调整居中卡片的弹跳速度

cardViewController.layout.flickVelocity = 0.5;

当前索引表示用户选择的卡片编号

NSInteger currentIndex = cardViewController.layout.currentIndex;

许可

此项目遵循 MIT 许可。请随意使用。
Michael Chen @yuhua_twit