项目作者: 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。
高级语言: Swift
项目地址: git://github.com/bestDew/ZKCycleScrollViewDemo.git
创建时间: 2019-03-09T03:45:34Z
项目社区:https://github.com/bestDew/ZKCycleScrollViewDemo

开源协议:

关键词:
banner cycle-scroll

下载


ZKCycleScrollView

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

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

特性

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

演示效果图

image

用法示例

  1. class ViewController: UIViewController {
  2. override func viewDidLoad() {
  3. super.viewDidLoad()
  4. let cycleScrollView = ZKCycleScrollView(frame: CGRect(x: 0.0, y: 0.0, width: 375.0, height: 65.0))
  5. cycleScrollView.delegate = self
  6. cycleScrollView.dataSource = self
  7. cycleScrollView.register(CustomCell.self, forCellWithReuseIdentifier: "cellReuseId")
  8. view.addSubview(cycleScrollView)
  9. }
  10. }
  11. extension ViewController: ZKCycleScrollViewDataSource {
  12. func numberOfItems(in cycleScrollView: ZKCycleScrollView) -> Int {
  13. return 5
  14. }
  15. func cycleScrollView(_ cycleScrollView: ZKCycleScrollView, cellForItemAt index: Int) -> ZKCycleScrollViewCell {
  16. let cell = cycleScrollView.dequeueReusableCell(withReuseIdentifier: "cellReuseId", for: index) as! CustomCell
  17. // TODO:
  18. return cell
  19. }
  20. }
  21. extension ViewController: ZKCycleScrollViewDelegate {
  22. func cycleScrollView(_ cycleScrollView: ZKCycleScrollView, didSelectItemAt index: Int) {
  23. // TODO:
  24. }
  25. }

更新记录

V2.0.1(2019/11/11):

1.支持 CocoaPods 导入:

  1. pod 'ZKCycleScrollView-Swift'

2.支持取消无限轮播:

  1. // 通过Xib 方式创建的,可直接在属性面板中直接设置 infiniteLoop 为 off
  2. // 通过纯代码方式创建的,需要设置 infiniteLoop 参数为 false
  3. public init(frame: CGRect, shouldInfiniteLoop infiniteLoop: Bool? = nil)

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

  1. // 设置默认从第三页开始显示
  2. ccleScrollView.loadCompletion = { [weak self] in
  3. guard let strongSelf = self else { return }
  4. strongSelf.cycleScrollView.scrollToItem(at: 3, animated: false)
  5. }

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

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

6.移除 -adjustWhenViewWillAppear 方法;

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

8.优化性能。