Skip to content

A simple customisable pull to refresh written in Swift 3.

License

Notifications You must be signed in to change notification settings

subinspathilettu/SJRefresh

Repository files navigation

SJRefresh

CI Status Version License Platform

SJRefresh is a light weight generic pull to refresh written in Swift 3.

sample_gif

Highlights

  • Supports multiple themes
  • Supports custom animation

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate SJRefresh into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
pod ’SJRefresh’, ‘1.0.0'
end

Then, run the following command:

$ pod install

Manually:

  • Download SJRefresh
  • Drag and drop SJRefresh directory to your project

Requirements

  • Xcode 8+
  • iOS 9.0+
  • Swift 3.0+

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Usage

Here is how you can use SJRefresh.

  • Import SJRefresh to your class
import SJRefresh
  • Specify your theme in AppDelegate.swift
SJRefresh.shared.setTheme(SJTheme())
  • Add refresh view to your control,

For in definite refresh animation, add following code

tableView.addRefreshView(definite: false,
		                 refreshCompletion: { (_) in

	//Your code here
	self.tableView.stopPullRefresh()
})

For definite refresh animation, add following code

tableView.addRefreshView(definite: true,
		                 refreshCompletion: { (_) in

	//Your code here
	self.tableView.setRefreshPrecentage(60)
	...
	self.tableView.setRefreshPrecentage(100)
})

Customize Refresh View

SJRefresh supports themes. So we can provide custom themes that supports SJRefreshThemeProtocol.

SJRefresh.shared.setTheme(<CUSTOM_THEME>)

Create custom Themes

To create a theme, create a class that confirm SJRefreshThemeProtocol

extension <YOUR_CLASS>: SJRefreshThemeProtocol {

	public func heightForRefreshView() -> CGFloat {
	
		return <CGFloat>
	}

	public func pullImageForRefreshView() -> UIImage {
	
		return <UIImage>
	}

	public func imagesForRefreshViewLoadingAnimation() -> [UIImage] {

		return <[UIImage]>
	}

	public func backgroundColorForRefreshView() -> UIColor {

		return <UIColor>
	}

	public func backgroundImageForRefreshView() -> UIImage? {
		
		return <UIImage>
	}
}

Author

Subins Jose, subinsjose@gmail.com

License

SJRefresh is available under the MIT license. See the LICENSE file for more info.

About

A simple customisable pull to refresh written in Swift 3.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •