Like this project? Star us above!
Pull to refresh is one of most frequently feature to be used in the all of apps, this component provides a easiest way to add pull to refresh feature for your table view.
tableView.cr.enablePullRefresh {
// Call data api from remote server.
get("http://xxx.com/api/productlist") { dataList in
// Update table view datasource
self.tableView.datasource = dataList
self.tableView.reloadData()
// Finish refresh
self.tableView.cr.stopRefresh()
}
}
As you saw above, we can simply enable this component for our table view, we may need to configure the tint color of the pull refresh view's background by:
tableView.cr.tintColor = UIColor.brown
Finally, we should call the remove()
method in the view controller's deinit
deinit {
tableView.cr.remove()
}
Check out the Sample project in the example directory to see more.
There are two approach to add CocoRongPullToRefresh
to your exist project.
CocoaPods is the recommended way to add CocoRongPullToRefresh to your project.
pod "CocoRongPullToRefresh", "~> 1.0"
pod install
command.import CocoRongPullToRefresh
.Run below command in Terminal.app:
$ git clone https://github.com/MellongLau/CocoRongPullToRefresh.git
or download directly, then copy CocoRongPullToRefresh
folder and add reference to your project.
Requires Swift 3.0 and iOS 8.0 and ARC.
If you're using CocoRongPullToRefresh in one of your own projects, let me know! I'll add a link to your profile/website/app right here on the front page. Feel free to email me at the address shown below.
Forks, patches and other feedback are welcome.
I'm Mellong, you can contact me by E-Mail: [email protected]
Website: http://www.devlong.com
Learn more? Follow my WeChat
public account mellong
:
MIT License