Customizable pull-to-refresh control,written in pure Swift.

Overview

What is it

This project is heavily inspired by CBStoreHouseRefreshControl which is Objective-C implemented. SurfingRefreshControl provides you a chance to use pure Swift alternative in your next app.

You can customize any desired shape through plist file like below two shapes:

alt tag

alt tag

How to use

Warning:Check out demo app directly if you're too lazy to read

You can attach it to any UIScrollView ( like UITableView UICollectionView) :

class func attachToScrollView(
scrollView:UIScrollView,
target:AnyObject,
refreshAction:Selector,
plist:String,
color:UIColor=UIColor.blackColor(),
lineWidth:CGFloat=2,
dropHeight:CGFloat=80,
scale:CGFloat=1,
horizontalRandomness:Int=150,
reverseLoadingAnimation:Bool=false,
internalAnimationFactor:CGFloat=1.0) -> SurfingRefreshControl

For instance:

self.surfingRefreshControl = SurfingRefreshControl.attachToScrollView(tableView, target: self,refreshAction:#selector(DemoViewController.refreshTriggered), plist: "surfing", color: UIColor.whiteColor(),lineWidth: 1.5, dropHeight: 120, scale: 1.0, horizontalRandomness: 100,  reverseLoadingAnimation: false, internalAnimationFactor: 0.8) 

Implement UIScrollViewDelegate in your UIViewController to notify SurfingRefreshControl your scrollView's movements:

override func scrollViewDidScroll(scrollView: UIScrollView) {
  	self.surfingRefreshControl.scrollViewDidScroll(scrollView)
}

override func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
	self.surfingRefreshControl.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}

When you're done with surfing,simply call

self.surfingRefreshControl.finishLoading()

How to customize your refresh:

SurfingRefreshControl make use of SurfingBarItem which actually is a UIView subclass, made of start point and end point to form a line.Imagine a squre need 4 line,thus need 4 SurfingBarItem,which equal to 4 start points and 4 end points.In conclusion,a square surfing refresh control would need a plist file of 4 start points and 4 end points,as shown below:

alt tag

Square SurfingRefreshControl output is:

alt tag

PaintCode to generate your startpoints and endpoints without too much hassle:

alt tag

Author

Peiwei Chen [email protected]
Blog

License

Copyright (c) 2016 Peiwei Chen [email protected]. See the LICENSE file for license rights and limitations (MIT).

You might also like...
An easy way to use pull-to-refresh.
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

GIFRefreshControl is a pull to refresh that supports GIF images as track animations.
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

Custom animated pull-to-refresh that can be easily added to UIScrollView
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

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

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

An easy way to use pull-to-refresh
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

PullToRefreshSwiftUI - Pull to refresh for SwiftUI
PullToRefreshSwiftUI - Pull to refresh for SwiftUI

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

✳️ 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).

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

Simple refresh control for iOS based on SpriteKit and Core Graphics
Simple refresh control for iOS based on SpriteKit and Core Graphics

RainyRefreshControl Simple refresh control for iOS based on SpriteKit and Core Graphics. Project inspired by concept of Yup Nguyen Installation Instal

Comments
  • Crash on iphone 4s simulator

    Crash on iphone 4s simulator

    Hi,

    The demo crashes on iPhone 4s Simulator with EXEC_BAD_INSTRUCTION on line 30 of SurfingBarItem.swift. I could only see this behaviour with the iPhone 4s Simulator.

    Any idea as to what's the problem here?

    Here's the backtrace:

    (lldb) bt
    * thread #1: tid = 0x2ecdb, 0x0009e35a surfingRefreshControlDemo`SurfingBarItem.setHorizontalRandomness(horizontalRandomness=100, dropHeight=120, self=0x79946850) -> () + 186 at SurfingBarItem.swift:30, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
      * frame #0: 0x0009e35a surfingRefreshControlDemo`SurfingBarItem.setHorizontalRandomness(horizontalRandomness=100, dropHeight=120, self=0x79946850) -> () + 186 at SurfingBarItem.swift:30
        frame #1: 0x00093893 surfingRefreshControlDemo`static SurfingRefreshControl.attachToScrollView(scrollView=0x7b2baa00, target=0x7993b1b0, refreshAction="refreshTriggered", plist="surfing", color=0x79624710, lineWidth=2, dropHeight=120, scale=1.10000002, horizontalRandomness=100, reverseLoadingAnimation=false, internalAnimationFactor=0.800000011, self=surfingRefreshControlDemo.SurfingRefreshControl) -> SurfingRefreshControl + 5731 at SurfingRefreshControl.swift:102
        frame #2: 0x0009b584 surfingRefreshControlDemo`DemoViewController.viewDidLoad(self=0x7993b1b0) -> () + 2548 at DemoViewController.swift:26
        frame #3: 0x0009b622 surfingRefreshControlDemo`@objc DemoViewController.viewDidLoad() -> () + 34 at DemoViewController.swift:0
        frame #4: 0x01576b72 UIKit`-[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
        frame #5: 0x0157b692 UIKit`-[UIViewController loadViewIfRequired] + 1384
        frame #6: 0x0157bab1 UIKit`-[UIViewController view] + 35
        frame #7: 0x01429340 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 69
        frame #8: 0x01429a5d UIKit`-[UIWindow _setHidden:forced:] + 304
        frame #9: 0x01429e13 UIKit`-[UIWindow _orderFrontWithoutMakingKey] + 49
        frame #10: 0x0143d551 UIKit`-[UIWindow makeKeyAndVisible] + 80
        frame #11: 0x0009d633 surfingRefreshControlDemo`AppDelegate.application(application=0x79722600, launchOptions=nil, self=0x7992d5f0) -> Bool + 483 at AppDelegate.swift:20
        frame #12: 0x0009d787 surfingRefreshControlDemo`@objc AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool + 199 at AppDelegate.swift:0
        frame #13: 0x013a018c UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 337
        frame #14: 0x013a16a8 UIKit`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3863
        frame #15: 0x013a8f0f UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 2010
        frame #16: 0x013ceb2c UIKit`__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3246 + 68
        frame #17: 0x013a5b8a UIKit`-[UIApplication workspaceDidEndTransaction:] + 163
        frame #18: 0x06d1f110 FrontBoardServices`__37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
        frame #19: 0x06d1ebe7 FrontBoardServices`__40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
        frame #20: 0x06d3c27f FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 23
        frame #21: 0x06d3c0ab FrontBoardServices`-[FBSSerialQueue _performNext] + 174
        frame #22: 0x06d3c4fa FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 52
        frame #23: 0x06d3b7e8 FrontBoardServices`FBSSerialQueueRunLoopSourceHandler + 33
        frame #24: 0x001bde5f CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
        frame #25: 0x001b3aeb CoreFoundation`__CFRunLoopDoSources0 + 523
        frame #26: 0x001b2f08 CoreFoundation`__CFRunLoopRun + 1032
        frame #27: 0x001b2846 CoreFoundation`CFRunLoopRunSpecific + 470
        frame #28: 0x001b265b CoreFoundation`CFRunLoopRunInMode + 123
        frame #29: 0x013a52da UIKit`-[UIApplication _run] + 540
        frame #30: 0x013aaeb9 UIKit`UIApplicationMain + 160
        frame #31: 0x0009da01 surfingRefreshControlDemo`main + 145 at AppDelegate.swift:12
        frame #32: 0x032efa25 libdyld.dylib`start + 1
    
    opened by hu55a1n1 1
  • Disable drag animation.

    Disable drag animation.

    How to disable drag animation? On the original version everything is going nicely into places and here everything is just random. So I would like to turn of that animation.

    opened by shvetsjr 1
Owner
Peiwei
Peiwei
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
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
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
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
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
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
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
Give pull-to-refresh & infinite scrolling to any UIScrollView with 1 line of code.

SVPullToRefresh + SVInfiniteScrolling These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities

Sam Vermette 4.9k Dec 1, 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