用 Swift 开发的弹性下拉刷新组件

NBQElasticPullToRefresh

以 Swift 开发的弹性下拉刷新组件

DGElasticPullToRefresh 派生

可在此处找到有关如何实现该弹跳效果的教程 here

要求

  • Xcode 11 或更高版本
  • iOS 11.0 或更高版本(可能适用于以前版本,但我们并未进行测试)
  • ARC
  • Swift 5.0

演示

打开并运行 Xcode 中的 NBQElasticPullToRefreshExample 项目以了解 NBQElasticPullToRefresh 的运行情况。

安装

CocoaPods

pod 'NBQElasticPullToRefresh'

手动

将 DGElasticPullToRefresh 文件夹添加到您的项目中。

示例用法

// Initialize tableView
let loadingView = DGElasticPullToRefreshLoadingViewCircle()
loadingView.tintColor = UIColor(red: 78/255.0, green: 221/255.0, blue: 200/255.0, alpha: 1.0)
tableView.dg_addPullToRefreshWithActionHandler({ [weak self] () -> Void in
    // Add your logic here
    // Do not forget to call dg_stopLoading() at the end
    self?.tableView.dg_stopLoading()
}, loadingView: loadingView)
tableView.dg_setPullToRefreshFillColor(UIColor(red: 57/255.0, green: 67/255.0, blue: 89/255.0, alpha: 1.0))
tableView.dg_setPullToRefreshBackgroundColor(tableView.backgroundColor!)

别忘了在视图控制器 deinit 中移除下拉刷新。这是一个临时解决方案。

deinit {
    tableView.dg_removePullToRefresh()
}

描述

添加下拉刷新,无需加载视图:

func dg_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void)

添加下拉刷新,带加载视图:

func dg_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void, loadingView: DGElasticPullToRefreshLoadingView?)

您可以使用