KRPullLoader 1.3.0

KRPullLoader 1.3.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release May 2019
SPMSupports SPM

Maintained by Krimpedance.



  • By
  • krimpedance

日本語

KRPullLoader

Version License Platform Download Carthage compatible CI Status

Features

  • Easy-to-use
  • Possibles both of pull refresh and load more.

Requirements

  • iOS 8.0+
  • Xcode 10.2+
  • Swift 5.0+

DEMO

To run the example project, clone the repo, and open KRPullLoaderDemo.xcodeproj from the DEMO directory.

or appetize.io

Installation

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"

Usage

(see sample Xcode project in /Demo)

Add views

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.

Add custom views

You can design loading views freely by making custom UIView in succession to KRPullLoadable protocol

Please refer to KRPullLoadView.swift or HorizontalPullLoadView.swift.

KRPullLoadable

/**
 Handler when KRPullLoaderState value changed.

 - parameter state: New state.
 - parameter type:  KRPullLoaderType.
*/
func didChangeState(_ state: KRPullLoaderState, viewType type: KRPullLoaderType)

KRPullLoaderState

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.

Contributing to this project

I'm seeking bug reports and feature requests.

Release Note

  • 1.3.0

    • Compatible with Swift 5.0.
    • Add method that pull to refresh programmatically (Only KRPullLoaderType.refresh)
  • 1.2.0

    • Compatible with Swift 4.2.

License

KRPullLoader is available under the MIT license. See the LICENSE file for more info.