LBCycleScrollView
Cycle scroll view for iOS. Use Objective-C.
使用方法
自定义分页控件循环滚动视图
LBPageControl *control1 = [[LBPageControl alloc] init];
control1.pageIndicatorImage = [UIImage imageNamed:@"control1"];
control1.currentPageIndicatorImage = [UIImage imageNamed:@"control2"];
LBCycleScrollView *scrollView1 = [LBCycleScrollView cycleScrollViewWithFrame:CGRectMake(0.f, 0.f, self.view.frame.size.width, 200.f) cellClass:[DemoCollectionViewCell_One class]];
scrollView1.delegate = self;
scrollView1.pageControl = control1;
scrollView1.pageControlAlignment = LBCycleScrollViewPageControlAlignmentRight | LBCycleScrollViewPageControlAlignmentBottom;
[self.view addSubview:scrollView1];
DemoModel *model1 = [DemoModel new];
model1.image = [UIImage imageNamed:@"img1"];
model1.string = @"Bei Jing";
DemoModel *model2 = [DemoModel new];
model2.image = [UIImage imageNamed:@"img2"];
model2.string = @"Hong Kong";
DemoModel *model3 = [DemoModel new];
model3.image = [UIImage imageNamed:@"img3"];
model3.string = @"New York";
DemoModel *model4 = [DemoModel new];
model4.image = [UIImage imageNamed:@"img4"];
model4.string = @"Paris";
scrollView1.itemArray = @[model1, model2, model3, model4];
[scrollView1 reloadData];
自定义垂直分页控件循环滚动视图
LBPageControl *control2 = [[LBPageControl alloc] init];
control2.pageControlDirection = LBPageControlDirectionVertical;
LBCycleScrollView *scrollView2 = [LBCycleScrollView cycleScrollViewWithFrame:CGRectMake(0.f, 210.f, self.view.frame.size.width, 100.f) cellClass:[DemoCollectionViewCell_Two class]];
scrollView2.delegate = self;
scrollView2.scrollTimeInterval = 4.f;
scrollView2.pageControlAlignment = LBCycleScrollViewPageControlAlignmentCenter | LBCycleScrollViewPageControlAlignmentLeft;
scrollView2.scrollDirection = LBCycleScrollViewScrollDirectionVertical;
scrollView2.pageControl = control2;
[self.view addSubview:scrollView2];
scrollView2.itemArray = @[UIColorFromRGB(0xFF8EAD), UIColorFromRGB(0xD18FFE), UIColorFromRGB(0xF6F87E)];
[scrollView2 reloadData];
带有自定义分页控制的无限循环滚动视图
LBPageControl *control3 = [[LBPageControl alloc] init];
control3.currentPageIndicatorImage = [UIImage imageNamed:@"control3"];
LBCycleScrollView *scrollView3 = [LBCycleScrollView cycleScrollViewWithFrame:CGRectMake(0.f, 320.f, self.view.frame.size.width, 200.f) cellClass:[DemoCollectionViewCell_One class]];
scrollView3.delegate = self;
scrollView3.scrollTimeInterval = 3.f;
scrollView3.cycleScrollEnabled = NO;
scrollView3.pageControlAlignment = LBCycleScrollViewPageControlAlignmentCenter | LBCycleScrollViewPageControlAlignmentTop;
scrollView3.pageControl = control3;
[self.view addSubview:scrollView3];
DemoModel *model5 = [DemoModel new];
model5.image = [UIImage imageNamed:@"img5"];
DemoModel *model6 = [DemoModel new];
model6.image = [UIImage imageNamed:@"img6"];
DemoModel *model7 = [DemoModel new];
model7.image = [UIImage imageNamed:@"img7"];
scrollView3.itemArray = @[model5, model6, model7];
[scrollView3 reloadData];
无时间控制循环滚动视图 - 自定义分页控制
LBPageControl *control4 = [[LBPageControl alloc] init];
control4.pageIndicatorSpacing = 15.f;
control4.pageIndicatorTintColor = [UIColor whiteColor];
control4.currentPageIndicatorTintColor = [UIColor orangeColor];
LBCycleScrollView *scrollView4 = [LBCycleScrollView new];
scrollView4.frame = CGRectMake(0.f, 530.f, self.view.frame.size.width, 100.f);
scrollView4.cellCls = [DemoCollectionViewCell_Two class];
scrollView4.delegate = self;
scrollView4.timingScrollingEnabled = NO;
scrollView4.pageControlAlignment = LBCycleScrollViewPageControlAlignmentBottom | LBCycleScrollViewPageControlAlignmentLeft;
scrollView4.pageControl = control4;
[self.view addSubview:scrollView4];
scrollView4.itemArray = @[UIColorFromRGB(0xBABABA), UIColorFromRGB(0xAB82FF), UIColorFromRGB(0xFFDEAD), UIColorFromRGB(0xD1EEEE), UIColorFromRGB(0x87CEFF)];
[scrollView4 reloadData];
下载示例项目并了解更多。
安装
CocoaPods
将 'LBCycleScrollView' 模块添加到您的 Podfile 中。运行 pod install 或 pod update。
手动
下载 LBCycleScrollView 子目录中的所有文件。将源文件添加到您的 Xcode 项目中。
需求
这个库需要iOS 8.0+和Xcode 7.0+。
许可证
LBCycleScrollView遵循MIT许可证。详细信息请见LICENSE文件。