项目作者: bestDew

项目描述 :
A simple and useful automatic infinite scroll view, more elegant implementation and more friendly API. Support Objective-C and Swift. 一款简单实用的轮播图控件,更优雅的实现,更友好的API。支持 Objective-C 和 Swift。
高级语言: Objective-C
项目地址: git://github.com/bestDew/ZKCycleScrollViewDemo-OC.git
创建时间: 2019-03-09T09:26:25Z
项目社区:https://github.com/bestDew/ZKCycleScrollViewDemo-OC

开源协议:

关键词:
banner cycle-scroll

下载


ZKCycleScrollView

ZKCycleScrollView是的一个功能强大的轮播视图。支持 Objective-CSwift

提示:下载完 Demo 后,需执行下 pod install才能运行。

特性

  • 高度可定制化
  • 支持 Xib 方式创建
  • 支持 CocoaPods 方式导入:pod 'ZKCycleScrollView'

演示效果图

image

用法示例

  1. @interface ViewController () <ZKCycleScrollViewDelegate, ZKCycleScrollViewDataSource>
  2. @end
  3. @implementation ViewController
  4. - (void)viewDidLoad {
  5. [super viewDidLoad];
  6. ZKCycleScrollView *cycleScrollView = [[ZKCycleScrollView alloc] initWithFrame:CGRectMake(0.f, 0.f, 375.f, 65.f)];
  7. cycleScrollView.delegate = self;
  8. cycleScrollView.dataSource = self;
  9. [cycleScrollView registerCellClass:[CustomCell class] forCellWithReuseIdentifier:@"cellReuseId"];
  10. [self.view addSubview:cycleScrollView];
  11. }
  12. #pragma mark -- ZKCycleScrollView DataSource
  13. - (NSInteger)numberOfItemsInCycleScrollView:(ZKCycleScrollView *)cycleScrollView {
  14. return 5;
  15. }
  16. - (__kindof ZKCycleScrollViewCell *)cycleScrollView:(ZKCycleScrollView *)cycleScrollView cellForItemAtIndex:(NSInteger)index {
  17. CustomCell *cell = [cycleScrollView dequeueReusableCellWithReuseIdentifier:@"cellReuseId" forIndex:index];
  18. // TODO:
  19. return cell;
  20. }
  21. #pragma mark -- ZKCycleScrollView Delegate
  22. - (void)cycleScrollView:(ZKCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  23. // TODO:
  24. }
  25. @end

更新记录

V2.0.1(2019/11/11):

1.支持 CocoaPods 导入:

  1. pod 'ZKCycleScrollView'

2.支持取消无限轮播:

  1. // 通过Xib 方式创建的,可直接在属性面板中直接设置 infiniteLoop 为 off
  2. // 通过纯代码方式创建的,需要使用下面这种初始化方法并设置 infiniteLoop 参数为 NO
  3. - (instancetype)initWithFrame:(CGRect)frame shouldInfiniteLoop:(BOOL)infiniteLoop NS_DESIGNATED_INITIALIZER;

3.支持设置默认显示页:

  1. // 设置默认从第三页开始显示
  2. __weak typeof(self) weakSelf = self;
  3. _cycleScrollView.loadCompletion = ^{
  4. __strong typeof(weakSelf) strongSelf = weakSelf;
  5. [strongSelf.cycleScrollView scrollToIndex:3 animated:NO];
  6. };

4.修复界面跳转时 cell 自动偏移的 bug;

5.修复在加载时就回调代理方法的 bug;

6.移除 -adjustWhenViewWillAppear 方法;

7.新增 -beginUpdates、-endUpdates、-scrollToIndex:animated:、-cellForItemAtIndex: 等方法,具体使用见Demo;

8.优化性能。