Giter VIP home page Giter VIP logo

kmyelasticpulltorefresh's Introduction

KMYElasticPullToRefresh

Elastic pull to refresh component developed in Swift

Inspired by this Dribbble post: Pull Down to Refresh by Hoang Nguyen

Tutorial on how this bounce effect was achieved can be found here.

Requirements

  • Xcode 8 or higher
  • iOS 9 or higher (may work on previous versions, just did not test it)
  • ARC
  • Swift 4.2

Demo

Open and run the KMYElasticPullToRefreshExample project in Xcode to see KMYElasticPullToRefresh in action.

Installation

CocoaPods

pod 'KMYElasticPullToRefresh'

Manual

Add KMYElasticPullToRefresh folder into your project.

Example usage

// Initialize tableView
let loadingView = KMYElasticPullToRefreshLoadingViewCircle()
loadingView.tintColor = UIColor(red: 78/255.0, green: 221/255.0, blue: 200/255.0, alpha: 1.0)
tableView.kmy_addPullToRefreshWithActionHandler({ [weak self] () -> Void in
    // Add your logic here
    // Do not forget to call kmy_stopLoading() at the end
    self?.tableView.kmy_stopLoading()
}, loadingView: loadingView)
tableView.kmy_setPullToRefreshFillColor(UIColor(red: 57/255.0, green: 67/255.0, blue: 89/255.0, alpha: 1.0))
tableView.kmy_setPullToRefreshBackgroundColor(tableView.backgroundColor!)

Do not forget to remove pull to refresh on view controller deinit. It is a temporary solution.

deinit {
    tableView.kmy_removePullToRefresh()
}

Description

Add pull to refresh without loading view:

func kmy_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void)

Add pull to refresh with loading view:

func kmy_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void, loadingView: KMYElasticPullToRefreshLoadingView?)

You can use built-in KMYElasticPullToRefreshLoadingViewCircle or create your own by subclassing KMYElasticPullToRefreshLoadingView and implementing these methods:

func setPullProgress(_ progress: CGFloat)
func startAnimating()
func stopLoading()

Remove pull to refresh:

func kmy_removePullToRefresh()

Set auto start loading:

func kmy_startLoading()

Change pull to refresh background color:

func kmy_setPullToRefreshBackgroundColor(_ color: UIColor)

Change pull to refresh fill color:

func kmy_setPullToRefreshFillColor(_ color: UIColor)

Contribution

Please feel free to submit pull requests. Cannot wait to see your custom loading views for this pull to refresh.

License

The MIT License (MIT)

kmyelasticpulltorefresh's People

Contributors

gontovnik avatar haawa799 avatar readmecritic avatar codeeagle avatar danielchristopher1 avatar lfarah avatar snakecharmer 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.