Name: SwiftRefresher
Owner: Wantedly, Inc.
Description: SwiftRefresher is one of the alternatives of UIRefreshControl.
Forked from: morizotter/SwiftRefresher
Created: 2016-11-09 01:57:24.0
Updated: 2017-03-03 08:49:23.0
Pushed: 2017-07-10 17:31:14.0
Size: 2884
Language: Swift
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
SwiftRefresher solves your problem on UIRefreshControl on UITableView in UIViewController! SwiftRefresher is one of the alternatives of UIRefreshControl. Moreover, it is very customizable!
Add codes below and add it to UITableView with srf_addRefresher
. The closure will be called when refresh starts.
refresher = RefresherView { [weak self] () -> Void in
self?.updateItems()
eView.srf_addRefresher(refresher)
And call srf_endRefreshing()
whenever/wherever your refreshing task finished.
bleView.srf_endRefreshing()
The view of SwiftRefresher is independent from its main system. The only requirement is to conform to SwfitRefresherEventReceivable
protocol. Default view is SimpleRefreshView
. You can use it with a little customization like this below:
refresher = Refresher { [weak self] () -> Void in
self?.updateItems()
esher.createCustomRefreshView { () -> SwfitRefresherEventReceivable in
return SimpleRefreshView(activityIndicatorViewStyle: .White)
eView.srf_addRefresher(refresher)
In this example, I changed SimpleRefreshView's activityIndicatorViewStyle to .White. But you can customize more with create your own refreh view!
Just create a view with conforming to SwfitRefresherEventReceivable
. SwfitRefresherEventReceivable
has one required function func didReceiveEvent(event: SwiftRefresherEvent)
. Through this function, refresher send the view the events. The events are below:
ic enum SwiftRefresherEvent {
case Pull(offset: CGPoint, threshold: CGFloat)
case StartRefreshing
case EndRefreshing
case RecoveredToInitialState
For example, preset SimpleRefreshView has this easy codes.
ic func didReceiveEvent(event: SwiftRefresherEvent) {
switch event {
case .Pull:
pullingImageView.hidden = false
case .StartRefreshing:
pullingImageView.hidden = true
activityIndicatorView.startAnimating()
case .EndRefreshing:
activityIndicatorView.stopAnimating()
case .RecoveredToInitialState:
break
}
RecoveredToInitialState
means that after EndRefreshing, the view will go back to initial state. And then the state becamed to the initial, this event will be called.
Just add to your Cartfile:
ub "morizotter/SwiftRefresher"
CocoaPods is a centralised dependency manager that automates the process of adding libraries to your Cocoa application. You can install it with the following command:
m update
m install cocoapods
ds --version
To integrate SwiftRefresher into your Xcode project using CocoaPods, specify it in your Podfile
and run pod install
.
form :ios, '8.1'
frameworks!
"SwiftRefresher", '~>0.9.0'
To install SwiftRefresher without a dependency manager, please add all of the files in /SwiftRefresher
to your Xcode Project.
Please file issues or submit pull requests for anything you?d like to see! We're waiting! :)
SwiftRefresher is released under the MIT license. Go read the LICENSE file for more information.