项目作者: Narek1994

项目描述 :
PullToRefresh for any kind of view.
高级语言: Swift
项目地址: git://github.com/Narek1994/NSVPullToRefresh.git
创建时间: 2019-09-19T08:07:55Z
项目社区:https://github.com/Narek1994/NSVPullToRefresh

开源协议:MIT License

下载


Customizable PullToRefresh for any kind of view

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Swift 5.0

Installation

NSVPullToRefresh is available through CocoaPods. To install
it, simply add the following line to your Podfile:

  1. pod 'NSVPullToRefresh'

Usage

import NSVPullToRefresh

  1. import NSVPullToRefresh

In a simple case you will just need to add PullToRefresh to your main view, it will automatically handle child ScrollView(TableView,CollectionView), if there is one, without blocking other gestures added to the view.

  1. view.addPullToRefresh { [weak self] in
  2. guard let strongSelf = self else {
  3. return
  4. }
  5. your code here
  6. DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
  7. strongSelf.view.hidePullToRefresh()
  8. })
  9. }

⚠️ Don’t forget to weakly capture self, to avoid reference cycling!
for hiding just call

  1. hidePullToRefresh()

on that view.

Creating custom PullToRefresh

Default it uses UIActivityIndicatorView, for customizing you will need to create any UIView which will implement LoadingView protocol. You will need to specify size of refresher, topOffset, and also implement startLoading and stopLoading methods. Optionally there is a speed property with default value of 1.

Progress of Refreshing

You can get the progress of refreshing by adding this callback. It will give value from 0 to 1.

  1. view.onProgress = { [weak self] progress in
  2. print(progress)
  3. }

Author

Narek1994, nareksimonyan94@gmail.com

License

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