Giter Site home page Giter Site logo

konroj / pulltorefreshkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leomobiledeveloper/pulltorefreshkit

0.0 2.0 0.0 8.62 MB

Pull to refresh in Swift, easy to use, easy to customize

License: MIT License

Ruby 1.85% Objective-C 0.84% Swift 97.31%

pulltorefreshkit's Introduction

PullToRefreshKit

Apps Using Downloads Version Platform Language License Build Status

The example project contains some hot App refresh example.

Taobao YouKu QQ Video QQ
Curve Yahoo Weather Dian Ping

Require

  • iOS 8
  • Swift 4.0

For Swift 3, See branch Swift3

Support

UITableView/UICollectionView/UIScrollView/UIWebView

  • Pull to refresh.
  • Pull/Tap to load more.
  • Pull left/right to load more(Currently only support chinese)
  • Elastic refresh
  • Easy to customize
  • English and Chinese

Install

CocoaPod

pod "PullToRefreshKit"

Carthage

github "LeoMobileDeveloper/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.

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.