English|简体中文
An easy way to use pull-to-refresh, Swift version of MJRefresh.
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate XSRefresh into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'XSRefresh'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate XSRefresh into your Xcode project using Carthage, specify it in your Cartfile
:
github "XaoflySho/XSRefresh"
Drag All files in the XSRefresh/Sources
folder to project.
import XSRefresh
func tableViewRefreshSetting() {
// Header, the drop-down refresh control.
tableView.xs.header = XSRefreshNormalHeader { [weak self] in
// Refreshing code...
// End refreshing.
self?.tableView.xs.header?.endRefreshing()
}
// Footer, the pull to refresh control.
tableView.xs.footer = XSRefreshAutoNormalFooter { [weak self] in
// Load or refreshing Code...
// End refreshing.
self?.tableView.xs.footer?.endRefreshing()
}
}
import XSRefresh
func tableViewRefreshSetting() {
// Header, the drop-down refresh control.
tableView.xs.header = XSRefreshNormalHeader(withRefreshing: self, action: #selector(refresh))
// Footer, the pull to refresh control.
tableView.xs.footer = XSRefreshAutoNormalFooter(withRefreshing: self, action: #selector(loadMoreData))
}
@objc func refresh() {
// Refreshing code...
// End refreshing.
tableView.xs.header?.endRefreshing()
}
@objc func loadMoreData() {
// Load or refreshing Code...
// End refreshing.
if noMoreData {
// No more data.
tableView.xs.footer?.endRefreshingWithNoMoreData()
} else {
// End refreshing.
tableView.xs.footer?.endRefreshing()
}
}
func tableViewRefreshSetting() {
XSRefreshNormalHeader { [weak self] in
// Do something...
}
.autoChangeTransparency(true)
.link(to: tableView)
XSRefreshAutoNormalFooter { [weak self] in
// Do something...
}
.autoChangeTransparency(true)
.link(to: tableView)
}
To see how the specification has been applied, see the example-readmes.
- Support for Carthage management tools
- Support for Swift package management tools
- Support horizontal scroll control, eg.CollectionView
- Support Swift Chaining Grammar
- ......
MIT © Xaofly Sho