Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/WXGBridgeQ/SwiftPullToRefresh
An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.
https://github.com/WXGBridgeQ/SwiftPullToRefresh
pull-to-refresh scrollview-compatible swift
Last synced: 3 months ago
JSON representation
An easy way to implement pull-to-refresh feature based on UIScrollView extension, written in Swift 4.
- Host: GitHub
- URL: https://github.com/WXGBridgeQ/SwiftPullToRefresh
- Owner: WXGBridgeQ
- License: mit
- Created: 2017-04-30T03:51:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T13:56:24.000Z (9 months ago)
- Last Synced: 2024-07-19T02:11:54.770Z (4 months ago)
- Topics: pull-to-refresh, scrollview-compatible, swift
- Language: Swift
- Homepage:
- Size: 3.15 MB
- Stars: 465
- Watchers: 8
- Forks: 56
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Logo](logo.png)
[![Build Status](https://travis-ci.org/WXGBridgeQ/SwiftPullToRefresh.svg)](https://travis-ci.org/WXGBridgeQ/SwiftPullToRefresh)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftPullToRefresh.svg)](https://cocoapods.org/pods/SwiftPullToRefresh)
[![Platform](https://img.shields.io/cocoapods/p/SwiftPullToRefresh.svg)](https://cocoapods.org/pods/SwiftPullToRefresh)
[![Language](https://img.shields.io/badge/language-swift-orange.svg)](https://swift.org/)
[![License](https://img.shields.io/badge/license-MIT-000000.svg)](https://github.com/WXGBridgeQ/SwiftPullToRefresh/blob/master/LICENSE)
[![codebeat badge](https://codebeat.co/badges/05eca7f9-68b2-4ca1-aa72-abe7edc5aff2)](https://codebeat.co/projects/github-com-wxgbridgeq-swiftpulltorefresh-master)# 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
```swift
scrollView.spr_setIndicatorHeader { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo01.gif)
#### Text Header
```swift
scrollView.spr_setTextHeader { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo02.gif)
#### Small GIF Header
```swift
scrollView.spr_setGIFHeader(data: data, isBig: false, height: 60) { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo03.gif)
#### GIF + Text Header
```swift
scrollView.spr_setGIFTextHeader(data: data) { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo04.gif)
#### Big GIF Header
```swift
scrollView.spr_setGIFHeader(data: data, isBig: true, height: 120) { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo05.gif)
#### Indicator Footer
```swift
scrollView.spr_setIndicatorFooter { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```or
```swift
scrollView.spr_setIndicatorAutoFooter { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo07.gif)
#### Text Footer
```swift
scrollView.spr_setTextFooter { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```or
```swift
scrollView.spr_setTextAutoFooter { [weak self] in
// do your action here
// self?.scrollView.spr_endRefreshing()
}
```![](SwiftPullToRefreshDemo/demo08.gif)
#### Clear header or footer
```swift
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.
```swift
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](https://videos.raywenderlich.com/courses/68-scroll-view-school/lessons/18))
![](SwiftPullToRefreshDemo/demo06.gif)
## 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](https://github.com/WXGBridgeQ/SwiftPullToRefresh/blob/master/LICENSE) for more info.