Latest 1.1.0
Homepage https://github.com/WXGBridgeQ/SwiftPullToRefresh
License MIT
Platforms ios 8.0
Authors

Logo

Build Status
Carthage compatible
CocoaPods Compatible
Platform
Language
License
codebeat badge

An easy way to implement pull-down-to-refresh and pull-up-to-load-more feature based on UIScrollView extension, written in Swift 3.

Provide default style header and footer controls which you can directly use in your project, and also support for customization. GIF is also supported.

Example usage

Indicator Header

scrollView.spr_setIndicatorHeader { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Text Header

scrollView.spr_setTextHeader { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Small GIF Header

scrollView.spr_setGIFHeader(data: data, isBig: false, height: 60) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

GIF + Text Header

scrollView.spr_setGIFTextHeader(data: data) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Big GIF Header

scrollView.spr_setGIFHeader(data: data, isBig: true, height: 120) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Indicator Footer

scrollView.spr_setIndicatorFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

or

scrollView.spr_setIndicatorAutoFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Text Footer

scrollView.spr_setTextFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

or

scrollView.spr_setTextAutoFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

Demo

Open and run the SwiftPullToRefreshDemo target in Xcode to see SwiftPullToRefresh in more actions.

Requirements

  • iOS 8.0
  • Swift 3.0

Installation

CocoaPods

use_frameworks!
pod 'SwiftPullToRefresh'

Carthage

github "WXGBridgeQ/SwiftPullToRefresh"

Manual

Add SwiftPullToRefresh folder into your project.

Customization

The framework is very easy to customize the use.

You just need to subclass the RefreshView and implement the methods below, then call spr_setCustomHeader(headerView:) or spr_setCustomFooter(footerView:) with your scrollView.

class CustomHeaderOrFooter: RefreshView {
    override func didUpdateState(_ isRefreshing: Bool) {
        // customize your view display with refresh state here
    }

    override func didUpdateProgress(_ progress: CGFloat) {
        // customize your view display with progress here
    }
}

You can also check the code of the super cat refresh which is a custom header in the SwiftPullToRefreshDemo target (Inspired by RayWenderlich)

Contribution

You are welcome to contribute to the project by forking the repo, modifying the code and opening issues or pull requests.

License

Available under MIT license. See the LICENSE for more info.

Latest podspec

{
    "name": "SwiftPullToRefresh",
    "version": "1.1.0",
    "summary": "An easy way to implement pull-down-to-refresh and pull-up-to-load-more feature based on UIScrollView extension, written in Swift 3.",
    "description": "An easy way to implement pull-down-to-refresh and pull-up-to-load-more feature based on UIScrollView extension, written in Swift 3. Provide default style header and footer controls which you can directly use in your project, and also support for customization. GIF is also supported.",
    "homepage": "https://github.com/WXGBridgeQ/SwiftPullToRefresh",
    "license": "MIT",
    "authors": {
        "Leo Zhou": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/WXGBridgeQ/SwiftPullToRefresh.git",
        "tag": "1.1.0"
    },
    "source_files": "SwiftPullToRefresh/*.{swift}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This