- Easy-to-use
- Possibles both of
pull refresh
andload more
.
- iOS 8.0+
- Xcode 10.0+
- Swift 4.2+
To run the example project, clone the repo, and open KRPullLoaderDemo.xcodeproj
from the DEMO directory.
or appetize.io
KRPullLoader is available through CocoaPods and Carthage. To install it, simply add the following line to your Podfile or Cartfile:
# CocoaPods
pod "KRPullLoader"
# Carthage
github "Krimpedance/KRPullLoader"
(see sample Xcode project in /Demo)
The simplest way:
let refreshView = KRPullLoadView()
refreshView.delegate = self
tableView.addPullLoadableView(refreshView, type: .refresh)
KRPullLoadView
is a simple loading view which consists of UIActivityIndicatorView
and UILabel
.
The change in the state can be watched by the delegate method.
type
has .refresh
and .loadMore
and can add either of UIScrollView's top and bottom.
You can design loading views freely by making custom UIView in succession to KRPullLoadable
protocol
Please refer to KRPullLoadView.swift or HorizontalPullLoadView.swift.
/**
Handler when KRPullLoaderState value changed.
- parameter state: New state.
- parameter type: KRPullLoaderType.
*/
func didChangeState(_ state: KRPullLoaderState, viewType type: KRPullLoaderType)
This is enum which shows the state of the scrolling.
.none
// hides the view.
.pulling(offset: CGPoint, threshold: CGFloat)
// Pulling.
// `offset` is pull offset (always <= 0).
// This state changes to `loading` when `offset` exceeded `threshold`.
.loading(completionHandler: ()->Void)
// Shows the view.
// You should call `completionHandler` when some actions have been completed.
I'm seeking bug reports and feature requests.
- 1.2.0 : Compatible with Swift 4.2.
- 1.1.3 : Compatible with Swift 4.1.
- 1.1.2 : Fixed bug of jerky scrolling. Improved performance.
- 1.1.1 : Fixed bug when calling completion handler immediately.
- 1.1.0 : Supported from iOS 8.0 and Swift 4.
KRPullLoader is available under the MIT license. See the LICENSE file for more info.