Swiftpack.co - FCXPods/SwiftFCXRefresh as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by FCXPods.
FCXPods/SwiftFCXRefresh 0.1.5
Pull to refresh in Swift.
⭐️ 29
🕓 1 week ago
iOS
.package(url: "https://github.com/FCXPods/SwiftFCXRefresh.git", from: "0.1.5")

SwiftFCXRefresh

CocoaPods compatible Carthage compatible Swift Package Manager compatible Platform Swift v5

SwiftFCXRefresh是一个使用Swift编写、用于上下拉刷新的控件。

特性

  • ☑ 普通上下拉刷新
  • ☑ 自动下拉刷新
  • ☑ 上拉无更多数据控制
  • ☑ 上下拉百分比显示
  • ☑ 自定义上下拉动画
  • ☑ 上拉底部间距控制

环境

  • Xcode 11+
  • Swift 5.2+
  • iOS 8.0+

如何导入

CocoaPods

pod 'SwiftFCXRefresh'

Carthage

github "FCXPods/SwiftFCXRefresh"

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/FCXPods/SwiftFCXRefresh", .upToNextMajor(from: "0.1.4"))
]

手动导入

把Sources下文件导入即可

如何使用

包含头文件

import SwiftFCXRefresh

上下拉刷新

//下拉刷新
headerRefreshView = tableView.addFCXRefreshHeader { [weak self] (refreshHeader) in
    self?.refreshAction()
    
//上拉加载更多
footerRefreshView = tableView.addFCXRefreshFooter { [weak self] (refreshFooter) in
    self?.loadMoreAction()
}

//自动上拉加载更多
footerRefreshView = tableView.addFCXRefreshAutoFooter { [weak self] (refreshFooter) in
    self?.loadMoreAction()
}

刷新自定义设置

//自动下拉刷新
headerRefreshView?.autoRefresh()

//自动上拉加载更多
footerRefreshView?.refreshType = .autoFooter

//上拉底部间距设置
footerRefreshView?.loadMoreBottomExtraSpace = 30

上下拉百分比

headerRefreshView?.pullingPercentHandler = { (percent) in
    headerPercentLabel.text = String.init(format: "%.2f%%", percent * 100)
}

footerRefreshView?.pullingPercentHandler = { (percent) in
    footererPercentLabel.text = String.init(format: "%.2f%%", percent * 100)
}

上下拉刷新、百分比链式调用

headerRefreshView = tableView.addFCXRefreshHeader { [weak self] (refreshHeader) in
    self?.refreshAction()
}.pullingPercentHandler(handler: { (percent) in
    //百分比
    print("current percent", percent)
})

footerRefreshView = tableView.addFCXRefreshFooter { [weak self] (refreshFooter) in
    self?.loadMoreAction()
}.pullingPercentHandler { (percent) in
    print("current percent", percent)
}

显示效果:

FCXRefresh.gif?raw=true

License

SwiftFCXRefresh is released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 29
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 year ago

First public release.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics