ESPullToRefresh is an easy-to-use component that give pull-to-refresh and infinite-scrolling implemention for developers.

Overview

Travis CocoaPods Carthage Compatible Swift v3 Twitter Twitter

中文介绍

ESPullToRefresh is an easy-to-use component that give pull-to-refresh and infinite-scrolling implemention for developers. By extension to UIScrollView, you can easily add pull-to-refresh and infinite-scrolling for any subclass of UIScrollView. If you want to customize its UI style, you just need conform the specified protocol.

Requirements

  • Xcode 8 or later
  • iOS 8.0 or later
  • ARC
  • Swift 5.0 or later

Features

  • Support UIScrollView and its subclasses UICollectionView UITableView UITextView
  • Pull-Down to refresh and Pull-Up to load more
  • Support customize your own style(s)

Demo

Download and run the ESPullToRefreshExample project in Xcode to see ESPullToRefresh in action.

Installation

CocoaPods

pod "ESPullToRefresh"

Carthage

github "eggswift/pull-to-refresh"

Manually

git clone https://github.com/eggswift/pull-to-refresh.git
open ESPullToRefresh

Usage

Default style:

Add ESPullToRefresh to your project

import ESPullToRefresh

Add default pull-to-refresh

self.tableView.es.addPullToRefresh {
	[unowned self] in
	/// Do anything you want...
	/// ...
	/// Stop refresh when your job finished, it will reset refresh footer if completion is true
	self.tableView.es.stopPullToRefresh(completion: true)
	/// Set ignore footer or not
	self.tableView.es.stopPullToRefresh(completion: true, ignoreFooter: false)
}

Add default infinite-scrolling

self.tableView.es.addInfiniteScrolling {
	[unowned self] in
	/// Do anything you want...
	/// ...
	/// If common end
	self.tableView.es.stopLoadingMore()
	/// If no more data
	self.tableView.es.noticeNoMoreData()
}

Customize Style

As effect:

PS: Load effect is from MeiTuan iOS app.

Customize refresh need conform the ESRefreshProtocol and ESRefreshAnimatorProtocol protocol.

Add customize pull-to-refresh

func es.addPullToRefresh(animator animator: protocol<ESRefreshProtocol, ESRefreshAnimatorProtocol>, handler: ESRefreshHandler)

Add customize infinite-scrolling

func es.addInfiniteScrolling(animator animator: protocol<ESRefreshProtocol, ESRefreshAnimatorProtocol>, handler: ESRefreshHandler)

Espried and auto refresh

ESPullToRefresh support for the latest expiration time and the cache refresh time, You need set an refreshIdentifier to your UIScrollView.

scrollView.refreshIdentifier = "Your Identifier" // Set refresh identifier
scrollView.expriedTimeInterval = 20.0 // Set the expiration interval

You can use es.autoPullToRefresh() method, when the time over the last refresh interval expires automatically refreshed.

scrollView.es.autoPullToRefresh()

let expried = scrollView.espried // expired or not

Remove

func es.removeRefreshHeader()
func es.removeRefreshFooter()

Sponsor

You can support the project by checking out our sponsor page. It takes only one click:

git-ad
This advert was placed by GitAds

About

ESPullToRefresh is developed and maintained by Vincent Li. If you have any questions or issues in using ESPullToRefresh, welcome to issue.
If you want to contribute to ESPullToRefresh, Please submit Pull Request, I will deal with it as soon as possible.

Twitter URL Twitter Follow

License

The MIT License (MIT)

Copyright (c) 2013-2020 eggswift

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • 我用pod导入之后不能正常使用

    我用pod导入之后不能正常使用

    self.tableView.es_addPullToRefresh { [weak self] in self?.tableView.es_stopPullToRefresh(completion: true) self?.tableView.es_stopPullToRefresh(completion: true, ignoreFooter: false) }

    提示错误是:value of type “UITableView” has no member ' es_addPullToRefresh'

    opened by zhanghongdou 42
  • infinite scroll 的问题

    infinite scroll 的问题

    我的app是开始时显示当天的内容,当tableview滑到底部时会从server端抓前一天的内容。

    但是我发现有时不是抓前一天的内容,而是抓前几天的内容。也就是时间都乱了。

    但不是都这样。很不稳定。有时显示的正常的。有时就不对。

    我看到另一个issue似乎提到了这个问题。不知道和我提的是否一样。

    您能看看么?

    多谢。

    opened by hoody4032 10
  • es_startPullToRefresh

    es_startPullToRefresh

    代码如下,当我在一个tableViewController中为tableView添加了下拉刷新和上拉加载,当使用es_startPullToRefresh方法时,发现,下拉刷新和上拉加载都调用了一遍,正常应该是只有下拉刷新被调用,不确定我是不是个例,我的页面中还使用了UISearchController,谢谢 self.tableView.es_addPullToRefresh { [weak self] in guard self != nil else {return} self?.getData() } self.tableView.es_addInfiniteScrolling { [weak self] in guard self != nil else {return} self?.loadMoreData() } self.tableView.es_startPullToRefresh()

    opened by fuboyou 8
  • This was called for many times, anything wrong with using it?

    This was called for many times, anything wrong with using it?

    `[self.contentView es_addInfiniteScrollingWithHandler:^{

        if (numeroCapituloAux != (int)book.caps) {
            [self carregaCapituloWithNumeroCapitulo:++numeroCapituloAux];
        }
    
        [self.contentView es_stopLoadingMore];
    
        self.contentView.contentOffset = CGPointZero;
        [self.contentView scrollRangeToVisible:NSMakeRange(0, 1)];
    
    }];`
    
    opened by alexliubj 6
  • Remove Observer crashes

    Remove Observer crashes

    removeObserver crashed in ESRefreshComponent - not always but often!

    *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <App.ESRefreshHeaderView 0x108b05430> for the key path "contentOffset" from <App.UITableView 0x1030ec200> because it is not registered as an observer.'

    opened by shobhz 5
  • Not working if there are no items in the collection

    Not working if there are no items in the collection

    Nothing happens if I try the pull down gesture on a empty UiCollectionView. This is a big issue as this is exactly the place where my users would want to check if something has been added on server.

    opened by amratab 4
  • Editing Text and Font for default pull to refresh and load more?

    Editing Text and Font for default pull to refresh and load more?

    Is there any way that I can edit the text of pull to refresh, load more and no more data without making new customize refresh control by using default control

    Any Help?

    opened by thihaaung6245 3
  • 嘿 man 有个bug

    嘿 man 有个bug

    dome中 把 DefaultTableViewController 中
    数据量改为2行 即 缩小到 并没有占满一屏 上拉刷新 改为

    self.tableView.es_addInfiniteScrolling {
                [weak self] in
    
    
    
                let minseconds = 0.1 * Double(NSEC_PER_SEC)   //此处改为0.1  加快反馈
    
    
    
    
                let dtime = dispatch_time(DISPATCH_TIME_NOW, Int64(minseconds))
                dispatch_after(dtime, dispatch_get_main_queue() , {
                    self?.page += 1
                    if self?.page <= 3 {
                        for _ in 1...1{
                            self?.array.append(" ")
                        }
                        self?.tableView.reloadData()
                        self?.tableView.es_stopLoadingMore()
                    } else {
                        self?.tableView.es_noticeNoMoreData()
                    }
                })
            }
    

    会使得在 ESRefreshFooterView.stopAnimating方法 中的scrollView.decelerating为true
    造成 执行了

    var contentOffset = scrollView.contentOffset
    contentOffset.y = min(contentOffset.y, scrollView.contentSize.height - scrollView.frame.size.height)
    scrollView.setContentOffset(contentOffset, animated: false)
    

    使cell弹到了 下半屏
    建议

     public override func stopAnimating() {
            guard let scrollView = scrollView else {
                return
            }
            self.animator.refreshAnimationDidEnd(self)
            self.animator.refresh(self, stateDidChange: .PullToRefresh)
            UIView .animateWithDuration(0.3, delay: 0, options: .CurveLinear, animations: { 
                self.animator.refresh(self, progressDidChange: 0.0)
                }) { (finished) in
                    super.stopAnimating()
            }
        }
    
    opened by harryzjm 3
  • UICollectionView 无法使用问题

    UICollectionView 无法使用问题

    当UICollectionView的 func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 0 } 时,下拉刷新无效?并且不在显示ESRefreshHeaderView

    opened by Johnson8888 3
  • Couldn't do pull to refresh when there is 1 or 2 items in UICollectionView

    Couldn't do pull to refresh when there is 1 or 2 items in UICollectionView

    Hello, I'm working on a project and used your amazing library, my issue happens when I have 1 or 2 cells in the collection view and the scroll fits the screen so I couldn't be able to do the pull to refresh

    IMG_2267

    opened by zaidqattan 2
  • iPhone OS Deployment Target

    iPhone OS Deployment Target

    Hey @eggswift,

    I keep getting this warning when I integrate ESPullToRefresh using Swift Package Manager

    The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99

    Any fix for this? Thank you btw, The library is great!

    opened by GarbuJohnG 0
  • Warning via SPM

    Warning via SPM

    Hey @eggswift ,

    can you update platform version to - platforms: [.iOS(.v9)]? or [.iOS(.v11)] to feature

    The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99.

    opened by iKorich 1
Releases(2.9.3)
Owner
Vincent Li
Life is brief, and then you die, you know?
Vincent Li
Easily add vertical and horizontal pull to refresh to any UIScrollView. Can also add multiple pull-to-refesh views at once.

This is a fork from the famous SVPullToRefresh pod with 2 additional functionalities: Can add multiple pull-to-refresh views into one single UIScrollV

Hoang Tran 42 Dec 28, 2022
An easy way to use pull-to-refresh.

MJRefresh An easy way to use pull-to-refresh ?? ✍??Release Notes: more details Contents New Features Dynamic i18n Switching SPM Supported Swift Chaini

M了个J 13.7k Jan 6, 2023
An easy way to use pull-to-refresh

CRRefresh an easy way to use pull-to-refresh, If you want to customize its UI style, you just need conform the specified protocol. We will not regular

CRAnimation 957 Dec 13, 2022
LCPullRefresh - Use UIActivityIndicatorView to provide a pull-to-refresh function for UIScrollView.

LCPullRefresh Use UIActivityIndicatorView to provide a pull-to-refresh function for UIScrollView. Requirements iOS 8.0+ Xcode 11.0+ Usage Pull-up refr

LiuChang 7 Aug 5, 2022
Animated, customizable, and flexible pull-to-refresh framework for faster and easier iOS development.

KafkaRefresh Animated, customizable, and flexible pull-to-refresh framework for faster and easier iOS development. Report bug · Request feature · 中文文档

H. H. Hsiang 1.2k Dec 11, 2022
✳️ SwiftUI Pull to Refresh (for iOS 13 and iOS 14) package.

Refreshable ✳️ SwiftUI Pull to Refresh (for iOS 13 and iOS 14) package. See complementary article at SwiftUI Pull to Refresh (for iOS 13 and iOS 14).

Geri Borbás 21 Dec 2, 2022
Pull to refresh functionality for any ScrollView in SwiftUI!

SwiftUIPullToRefresh Pull to refresh is a common UI pattern, supported in UIKit via UIRefreshControl. (Un)surprisingly, it's also unavailable in Swift

Gordan Glavaš 185 Dec 29, 2022
Elastic pull to refresh for iOS developed in Swift

DGElasticPullToRefresh Elastic pull to refresh compontent developed in Swift Inspired by this Dribbble post: Pull Down to Refresh by Hoang Nguyen Tuto

Danil Gontovnik 3.7k Jan 3, 2023
Animated "Pull To Refresh" Library for UIScrollView.

PullToBounce Animated "Pull To Refresh" Library for UIScrollView. You can add animated "pull to refresh" action to your UIScrollView, UITableView and

Takuya Okamoto 1.9k Dec 5, 2022
A pull-down-to-refresh control for iOS that plays pong, originally created for the MHacks III iOS app

BOZPongRefreshControl A pull-down-to-refresh control for iOS that plays pong Installation It's on CocoaPods! Put pod 'BOZPongRefreshControl' in your P

Ben Oztalay 885 Dec 12, 2022
Fully customizable pull-to-refresh control inspired by Storehouse iOS app

CBStoreHouseRefreshControl What is it? A fully customizable pull-to-refresh control for iOS inspired by Storehouse iOS app ![screenshot1] (https://s3.

Suyu Zhang 4k Jan 6, 2023
Customizable pull-to-refresh control,written in pure Swift.

What is it This project is heavily inspired by CBStoreHouseRefreshControl which is Objective-C implemented. SurfingRefreshControl provides you a chanc

Peiwei 55 Aug 21, 2022
One gesture, many actions. An evolution of Pull to Refresh.

MNTPullToReact MNTPullToReact is an extended evolution of the famous Pull to Refresh interaction. The main idea comes from a unique question: can the

Mention 777 Nov 20, 2022
Play BreakOut while loading - A playable pull to refresh view using SpriteKit

BreakOutToRefresh Play BreakOut while loading - A playable pull to refresh view using SpriteKit BreakOutToRefresh uses SpriteKit to add a playable min

Dominik Hauser 2.5k Dec 29, 2022
GIFRefreshControl is a pull to refresh that supports GIF images as track animations.

GIFRefreshControl GIFRefreshControl is a pull to refresh that supports GIF images as track animations. Installation You have multiple choices here: Co

Kevin Delannoy 163 Oct 4, 2022
Pull-to-refresh animation in UICollectionView with a sticky header flow layout, written in Swift :large_orange_diamond:

ReplaceAnimation Implementation of Zee Young's Dribbble animation (https://dribbble.com/shots/2067564-Replace) Info I really liked Zee Young's animati

Alex Türk 957 Sep 13, 2022
Custom animated pull-to-refresh that can be easily added to UIScrollView

PullToMakeSoup Custom animated pull-to-refresh that can be easily added to UIScrollView Check this article on our blog to know more details about anim

Yalantis 1.9k Dec 17, 2022
PullToRefreshSwiftUI - Pull to refresh for SwiftUI

PullToRefreshSwiftUI Pull to refresh for SwiftUI. Usage with @State import Swift

Dmitry Kononchuk 1 Feb 28, 2022
Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy.

EasyBackgroundRefresh Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy. Usage For fast refres

Yonat Sharon 6 Dec 5, 2022