SJRefresh is a light weight generic pull to refresh written in Swift 3.
- Supports multiple themes
- Supports custom animation
To run the example project, clone the repo, and run pod install from the Example directory first.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapodsTo 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'
endThen, run the following command:
$ pod install- Download SJRefresh
- Drag and drop SJRefresh directory to your project
- Xcode 8+
- iOS 9.0+
- Swift 3.0+
- 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.
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)
})SJRefresh supports themes. So we can provide custom themes that supports SJRefreshThemeProtocol.
SJRefresh.shared.setTheme(<CUSTOM_THEME>)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>
}
}Subins Jose, subinsjose@gmail.com
SJRefresh is available under the MIT license. See the LICENSE file for more info.
