All Projects → zevwings → ZVRefreshing

zevwings / ZVRefreshing

Licence: MIT license
A pure-swift and wieldy refresh component.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to ZVRefreshing

Closures
Swifty closures for UIKit and Foundation
Stars: ✭ 1,720 (+5831.03%)
Mutual labels:  carthage, uiscrollview
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+11606.9%)
Mutual labels:  carthage, uiscrollview
Silentscrolly
Scroll to hide navigationBar, tabBar and toolBar.
Stars: ✭ 79 (+172.41%)
Mutual labels:  carthage, uiscrollview
Pulltomakesoup
Custom animated pull-to-refresh that can be easily added to UIScrollView
Stars: ✭ 1,928 (+6548.28%)
Mutual labels:  carthage, uiscrollview
Tkswitchercollection
An animation switch collection
Stars: ✭ 877 (+2924.14%)
Mutual labels:  widget, carthage
SwiftFCXRefresh
Pull to refresh in Swift.
Stars: ✭ 29 (+0%)
Mutual labels:  carthage, refreshcontrol
Tkdotsegment
TKDotSegment is a segment with dot animation
Stars: ✭ 103 (+255.17%)
Mutual labels:  widget, carthage
StickyHeader
📐 Library helping to add a sticky header to an UIScrollView
Stars: ✭ 18 (-37.93%)
Mutual labels:  carthage, uiscrollview
keyboard layout
Keyboard switcher for Awesome WM with additional layouts
Stars: ✭ 48 (+65.52%)
Mutual labels:  widget
iOS-Today-Extension-Simple-Tutorial
iOS Today Extension Simple Tutorial
Stars: ✭ 24 (-17.24%)
Mutual labels:  widget
GCXTrustPolicy
SSL pinning and trust validation framework for iOS
Stars: ✭ 21 (-27.59%)
Mutual labels:  carthage
DPVideoMerger-Swift
Multiple videos merge in one video with manage scale & aspect ratio and also merge videos to grid matrix layout for Swift.
Stars: ✭ 49 (+68.97%)
Mutual labels:  carthage
sqlops-widgets
SQL Operations Studio Dashboard Widgets - including Always ON
Stars: ✭ 22 (-24.14%)
Mutual labels:  widget
Hola
Light-weight Onboard/Walkthrough UIView/UIImage representer ⏪ & ⏩ ⏫ & ⏬
Stars: ✭ 40 (+37.93%)
Mutual labels:  uiscrollview
cumulocity-app-builder
The Application Builder for Cumulocity provides a simple, coding-free way to create new applications inside Cumulocity. Application Builder is an open-source tool for you to create web applications in a no-code environment. Created by Global Presales.
Stars: ✭ 18 (-37.93%)
Mutual labels:  widget
carhacking
car hacking tools
Stars: ✭ 40 (+37.93%)
Mutual labels:  carthage
SwiftMan
Swift extensions and utils classes
Stars: ✭ 31 (+6.9%)
Mutual labels:  carthage
nl.fokkezb.button
Bootstrap Button widget for Appcelerator (Titanium)
Stars: ✭ 72 (+148.28%)
Mutual labels:  widget
DailyImageWidget
Android 桌面小部件(widget)日签 Or 日历,可作为桌面日历。Just For Fun! 🎮
Stars: ✭ 30 (+3.45%)
Mutual labels:  widget
ws-repl
MIGRATED TO https://vcs.rowanthorpe.com/rowan/ws-repl - THIS IS AN ARCHIVED VERSION... Arbitrary REPL in a web-page using websocketd
Stars: ✭ 38 (+31.03%)
Mutual labels:  widget

ZVRefreshing


ZVRefreshing is a pure-swift and wieldy refresh component.

中文文档

Requirements

  • iOS 8.0+
Swift Version Repo Version
Swift 5.0 > 2.2.0
Swift 4.2 < 2.1.3

Installation

Cocoapod

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.

You can install Cocoapod with the following command

$ sudo gem install cocoapods

To integrate ZVRefreshing into your project using CocoaPods, specify it into your Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
    use_frameworks!
    pod 'ZVRefreshing' ~> '2.0.0'
end

Then,install your dependencies with CocoaPods.

$ pod install

Carthage

Carthage is intended to be the simplest way to add frameworks to your application.

You can install Carthage with Homebrew using following command:

$ brew update
$ brew install carthage

To integrate ZVRefreshing into your project using Carthage, specify it into your Cartfile

github "zevwings/ZVRefreshing" ~> 0.0.1

Then,build the framework with Carthage using carthage update and drag ZVRefreshing.framework into your project.

Note:

The framework is under the Carthage/Build, and you should drag it into Target -> Genral -> Embedded Binaries

Manual

Download this project, And drag ZRefreshing.xcodeproj into your own project.

In your target’s General tab, click the ’+’ button under Embedded Binaries

Select the ZRefreshing.framework to Add to your platform.

Demo

Appetize

You can use online demo on Appetize

Genaral Usage

When you need add a refresh widget, you can use import ZVRefreshing

Initialize

There is three ways to initialize this widget.

  • Target-Action
let header = ZVRefreshNormalHeader(target: NSObject, action: Selector)
self.tableView.header = header
  • Block
let header = ZVRefreshNormalHeader(refreshHandler: { [weak self] in 
    // your codes    
})
self.tableView.header = header
  • None-parameters
let header = RefreshHeader()
self.tableView.header = header

if you initialize the widget by none-parameters way, you can add refresh handler block or target-action with following code:

  1. add a refresh handler
// add refresh handler
header?.refreshHandler = {
    // your codes            
}
  1. add a Target-Action
// add refresh target-action
header?.addTarget(Any?, action: Selector)
  1. add a Target-Action-UIControlEvents.valueChanged
// The ZVRefreshComponent extend from UIControl, When isRefreshing properties changed will send a UIControlEvents.valueChanged event.
header?.addTarget(Any, action: Selector, for: .valueChanged)

Functions

The functions is same for header and footer.

  1. beginRefreshing()

The widget begin enter into refreshing status.

self.tableView.header?.beginRefreshing()
  1. endRefreshing()

The widge begin enter into idle status.

self.tableView.header?.endRefreshing()
  1. setTitle(_:forState:) To custom the title for widget, this function in ZVRefreshStateHeader.
header.setTitle("pull to refresh...", forState: .idle)
header.setTitle("release to refresh...", forState: .pulling)
header.setTitle("loading...", forState: .refreshing)

or

 footer.setTitle("pull to refresh...", forState: .idle)
 footer.setTitle("release to refresh...", forState: .pulling)
 footer.setTitle("loading...", forState: .refreshing)
 footer.setTitle("no more data", forState: .noMoreData)
  1. setImages(_:forState:) To custom the images for widget, this function in ZVRefreshAnimationHeader, you can use it as following code, also you can extend a subclass, like Example
self.setImages(idleImages, forState: .idle)
self.setImages(refreshingImages, forState: .pulling)
self.setImages(refreshingImages, forState: .refreshing)

Properties

Header

  1. lastUpdatedTimeKey To storage the last time using this widget, if it dose not set, all your widget will shared a key com.zevwings.refreshing.lastUpdateTime
header.lastUpdatedTimeKey = "custom last updated key"
  1. ignoredScrollViewContentInsetTop

when your table set contentInset property, you should set it, for example:

self.tableView.contentInset = UIEdgeInsets(top: 30, left: 0, bottom:0, right: 0)
header.ignoredScrollViewContentInsetTop = 30
  1. lastUpdatedTimeLabel

To custom the UILabel properties for lastUpdatedTimeLabel, for example:

// hide the lastUpdatedTimeLabel
header.lastUpdatedTimeLabel.isHidden = true

or

// set the font for lastUpdatedTimeLabel
header.lastUpdatedTimeLabel.font = .systemFont(ofSize: 16.0)
  1. lastUpdatedTimeLabelText

To custom the format for showing last time.

header.lastUpdatedTimeLabelText = { date in

    if let d = date {
        let formatter = DateFormatter()
        formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        return "Last updated:\(formatter.string(from: d))"
    }
    return "There is no record"
}

Footer

  1. isAutomaticallyHidden To set the automatically hidden for widget, default is true
footer.isAutomaticallyHidden = false
  1. ignoredScrollViewContentInsetBottom when your table set contentInset property, you should set it, for example:
self.tableView.contentInset = UIEdgeInsets(top:0, left: 0, bottom:30, right: 0)
footer.ignoredScrollViewContentInsetBottom = 30
  1. isAutomaticallyRefresh To set the automatically refresh for widget, default is true, this property in ZVRefreshAutoFooter
footer.isAutomaticallyRefresh = false

Common

The following properties is same for header and footer.

  1. labelInsetLeft To set the empty width between activityIndicator an label.
header.labelInsetLeft = 32.0
  1. activityIndicator To custom the properties for activityIndicator, the properties @see ZActivityIndicatorView

  2. tintColor To custom the color for all sub-widget.

header.tintColor = .black
  1. stateLabel To custom the UILabel properties for stateLabel, for example:
// hide the stateLabel
header.stateLabel.isHidden = true

or

// set the font for stateLabel
header.stateLabel.font = .systemFont(ofSize: 16.0)
  1. animationView

To custom the UIImageView properties for stateLabel, for example:

Custom Usage

You can extend ZVRefreshComponent or it's sub-class to custom your own refresh widget. like Example.

Properties

  1. state

To custom you needed when refresh state changed.

open var state: ZVRefreshComponent.State
  1. pullingPercent

To custom you needed when widget position changed.

open var pullingPercent: CGFloat
  1. tintColor

To custom you own widget color.

open override var tintColor: UIColor!

Functions

  1. prepare

To define your own controls, call at init(frame: CGRect).

open func prepare() {}
  1. placeSubViews

To set your own constrols size and position, call at layoutSubviews().

open func placeSubViews() {}
  1. scrollViewContentOffsetDidChanged

To observe the UIScrollView.contentOffset, call at UIScrollView.contentOffset value changed.

open func scrollViewContentOffsetDidChanged(_ change: [NSKeyValueChangeKey: Any]?) {}
  1. scrollViewContentSizeDidChanged

To observe the UIScrollView.contentSize, call at UIScrollView.contentSize value changed.

open func scrollViewContentSizeDidChanged(_ change: [NSKeyValueChangeKey: Any]?) {}
  1. scrollViewPanStateDidChanged

To observe the UIScrollView.panGestureRecognizer.state, call at UIScrollView.panGestureRecognizer.state value changed.

open func scrollViewPanStateDidChanged(_ change: [NSKeyValueChangeKey: Any]?) {}

Rx Support

If you want use RxSwift, refer to ZVRefreshing+Rx.swift.

Then, you can use the follow codes to start a refresh action.

Observable.just(true)
    .asDriver(onErrorJustReturn: false)
    .drive(flatHeader!.rx.isRefreshing)
    .disposed(by: disposeBag)

Or, you can use this codes to observe the refreshing state.

flatHeader?.rx.refresh
    .subscribe(onNext: { isRefreshing in
        print("onNext isRefreshing : \(isRefreshing)")
    }, onError: { err in
        print("err : \(err)")
    }, onCompleted: {
        print("completed")
    }, onDisposed: {
        print("disposed")
    }).disposed(by: disposeBag)

More Usage

You can refer to the Example for more usage.

Issue or Suggestion

You can issue me on GitHub or send a email[email protected]. If you have a good idea, tell me. thanks.

License

ZVRefreshing distributed under the terms and conditions of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].