Giter Club home page Giter Club logo

refresher's Introduction

Refresher: Pull to refresh in Swift

Build Status

Refresher is pull to refresh library written in Swift. It provides easy to use UIScrollView methods to add pull to refresh to your view. Refresher also supports custom pull to refresh views.

##Usage

###Basic usage

tableView.addPullToRefreshWithAction {
	NSOperationQueue().addOperationWithBlock {
    	sleep(2)
        NSOperationQueue.mainQueue().addOperationWithBlock {
        	self.tableView.stopPullToRefresh()
        }
    }
}

###Custom views

Refresher supports custom subclasses of PullToRefreshView. Then, just pass your custom view in addPullToRefreshWithAction:

tableView.addPullToRefreshWithAction({           
  	NSOperationQueue().addOperationWithBlock {
   		sleep(2)
        NSOperationQueue.mainQueue().addOperationWithBlock {
        	self.tableView.stopPullToRefresh()
        }
    }
}, withView: CustomPullToRefreshView())

Methods that you would probably want to override:

  • func initialize() - Called when the view is created (either by InterfaceBuilder or using init()). Do setup like adding subviews etc. here.
  • func stateChanged() - Called whenever the state of the PullToRefreshView changes. Update for example a label's text here.
  • func startAnimating() - Called when user release finger from phone and when loading actually starts. Here you need to start your animations.
  • func stopAnimating() - Called when loading is over. Stop your animations here.
  • func changeProgress(progress: CGFloat) - Called when user is pulling view. If you want to implement some progress like behaviour on pull this method is called.

##Requirements

  • Xcode 6
  • iOS 8.0

##Installation

Method 1:

  1. Add Refresher as a git submodule into your top-level project directory or simply copy whole folder
  2. Find PullToRefresh.xcodeproj and drag it into the file navigator of your app project.
  3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  4. Under "General" panel go to "Linked Frameworks and Libraries" and add Refresher.framework

Method 2:

  1. Simply download Refresher
  2. Build it and you should find Refresher.framework under "Products" group.
  3. Right click on it and select "Show in Finder" option.
  4. Just drag and drop Refresher.framework to your project

##Examples

Refresher: preview default Refresher: preview beat Refresher: preview pacman

##Credits

Refresher is created by Josip Ćavar and inspired by SVPullToRefresh. If you have suggestions or bug reports, feel free to send pull request or create new issue.

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.