Git Product home page Git Product logo

nsvpulltorefresh's Introduction

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:

pod 'NSVPullToRefresh'

Usage

import NSVPullToRefresh

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.

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

โš ๏ธ Don't forget to weakly capture self, to avoid reference cycling! for hiding just call

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.

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

Author

Narek1994, [email protected]

License

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

nsvpulltorefresh's People

Contributors

narek1994 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.