要运行示例项目,请首先克隆仓库,然后从 Example 目录中运行 pod install
首先,您需要从 PXRotatorBaseViewModel
子类化并实现您自定义视图的位置上的 carousel:viewForItemAtIndex:reusingView:
方法。
然后创建一个 viewModel 并设置您的数据源。
最后创建一个 rotatorView 并将其绑定到您的 viewModel。
您可以为 rotatorView 添加自定义的分页控件。我已经实现了一个,您可以修改它或自己编写一个。
DKRotatorDemoViewModel *viewModel = [DKRotatorDemoViewModel new];
viewModel.displayItems = [@[@"Hello",@"Nice",@"to",@"meet",@"you!"] mutableCopy];
PXRotatorView *rotatorView = [[PXRotatorView alloc] initWithFrame:self.view.frame];
rotatorView.interval = 1;
[self.view addSubview:rotatorView];
[rotatorView bindViewModel:self.viewModel];
[rotatorView addDefaultPageControl];
[rotatorView updatePageControl];
iciaros 和 ReactiveCocoa
PXRotatorView 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 即可
pod "PXRotatorView"
drinking, [email protected]
PXRotatorView 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。