Coder Social home page Coder Social logo

nhnam / pulltorefreshkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leomobiledeveloper/pulltorefreshkit

0.0 2.0 0.0 8.56 MB

Simple way to pull to refresh in Swift,easy to use,easy to customize

License: MIT License

Ruby 1.06% Swift 98.48% Objective-C 0.47%

pulltorefreshkit's Introduction

PullToRefreshKit

Version Platform Language License

**The example project contains some hot App refresh example. **

Taobao YouKu QQ Video QQ
Curve Yahoo Weather Dian Ping

Require

  • iOS 8
  • Swift 3.0

For Swift 2.3, See branch Swift2 ##Support

UITableView/UICollectionView/UIScrollView/UIWebView

  • Add pull to refresh within on call. Support refresh result
  • Add pull to load more within one call
  • Add pull left/right to load more(Currently only support chinese)
  • Support Elastic refresh
  • Easy to customize
  • Support English and Chinese

Install

CocoaPod

pod "PullToRefreshKit"

Carthage

github "nhnam/PullToRefreshKit"

Useage

###Pull down to refresh

 self.tableView.setUpHeaderRefresh { [weak self] in
    delay(1.5, closure: { 
         self?.tableView.endHeaderRefreshing(.Success)
    })
 }

Add a delay if you want user to see the result of refresh result

self?.tableView.endHeaderRefreshing(.Success,delay: 0.5)

###Pull up to load more

Support three mode to fire refresh action

  • Tap
  • Scroll
  • Scroll and Tap
 self.tableView.setUpFooterRefresh {  [weak self] in
     delay(1.5, closure: {
         self?.tableView.endFooterRefreshing()
     })
 }

###Pull left to exit

 scrollView.setUpLeftRefresh { [weak self] in
     self?.navigationController?.popViewControllerAnimated(true)
 }

###Pull right to enter

 scrollView.setUpRightRefresh { [weak self] in
     let nvc = DefaultBannerController()
     self?.navigationController?.pushViewController(nvc, animated: true)
 }

###Config the default refresh text PullToRefershKit offer SetUp operator,for example

self.tableView.setUpHeaderRefresh { [weak self] in
    delay(1.5, closure: {
        self?.tableView.endHeaderRefreshing(.Success)
    })
}.SetUp { (header) in
    header.setText("Pull to refresh", mode: .pullToRefresh)
    header.setText("Release to refresh", mode: .releaseToRefresh)
    header.setText("Success", mode: .refreshSuccess)
    header.setText("Refreshing...", mode: .refreshing)
    header.setText("Failed", mode: .refreshFailure)
    header.setText("Error", mode: .refreshError)
    header.textLabel.textColor = UIColor.orangeColor()
    header.imageView.image = nil
}

###Customize

You just need to write a UIView sub class,and make it conforms to these protocols

  • RefreshableHeader
  • RefreshableFooter
  • RefreshableLeftRight

For exmaple,to create a custom header

    //Distance from top when in refreshing state
    func heightForRefreshingState()->CGFloat
   
    //Will enter refreshing state,change view state to refreshing in this function
    func didBeginrefreshingState()

    //The refreshing task is end.Refresh header will hide.Tell user the refreshing result here.
    func didBeginEndRefershingAnimation(result:RefreshResult)
    
    //Refresh header is hidden,reset all to inital state  here
    func didCompleteEndRefershingAnimation(result:RefreshResult)
    
    //Distance to drag to fire refresh action ,default is heightForRefreshingState
    optional func heightForFireRefreshing()->CGFloat
    
    //Percent change during scrolling
    optional func percentUpdateDuringScrolling(percent:CGFloat)
    
    //Duration of header hide animation
    optional func durationWhenEndRefreshing()->Double
    

Author

Leo, [email protected]

License

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

pulltorefreshkit's People

Contributors

leomobiledeveloper avatar nhnam avatar

Watchers

James Cloos 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.