Skip to content
An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SwiftPullToRefresh.xcodeproj convert to Swift 5 Mar 27, 2019
SwiftPullToRefresh Don't use UIScreen for RefreshView Width Jul 11, 2019
SwiftPullToRefreshDemo convert to Swift 4.2 Oct 17, 2018
.gitignore refactor code Jun 4, 2017
.travis.yml bump version to 3.0.1 Oct 17, 2018
LICENSE Initial commit Apr 30, 2017
README.md add clear methods for header and footer May 21, 2018
SwiftPullToRefresh.podspec bump version to 3.1 Mar 27, 2019
logo.png

README.md

Logo

Build Status Carthage compatible CocoaPods Compatible Platform Language License codebeat badge

SwiftPullToRefresh

An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.

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()
}

Clear header or footer

scrollView.spr_clearHeader()
scrollView.spr_clearFooter()

Demo

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

Requirements

  • iOS 8.0
  • Swift 4.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(_:) or spr_setCustomFooter(_:) 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.

You can’t perform that action at this time.