XSRefresh 0.1.2

XSRefresh 0.1.2

Maintained by Xaofly Sho.



XSRefresh 0.1.2

  • By
  • Xaofly Sho

English|简体中文

XSRefresh GitHub license podversion Carthage

An easy way to use pull-to-refresh, Swift version of MJRefresh.

Release notes

Install

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate XSRefresh into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'XSRefresh'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate XSRefresh into your Xcode project using Carthage, specify it in your Cartfile:

github "XaoflySho/XSRefresh"

Manual

Drag All files in the XSRefresh/Sources folder to project.

Usage

Quick start

import XSRefresh

func tableViewRefreshSetting() {
  // Header, the drop-down refresh control.
  tableView.xs.header = XSRefreshNormalHeader { [weak self] in
    // Refreshing code...
	  
    // End refreshing.
    self?.tableView.xs.header?.endRefreshing()
  }
	
  // Footer, the pull to refresh control.
  tableView.xs.footer = XSRefreshAutoNormalFooter { [weak self] in
    // Load or refreshing Code...
    
    // End refreshing.
    self?.tableView.xs.footer?.endRefreshing()
  }
}

More

import XSRefresh

func tableViewRefreshSetting() {
  // Header, the drop-down refresh control.
  tableView.xs.header = XSRefreshNormalHeader(withRefreshing: self, action: #selector(refresh))
  // Footer, the pull to refresh control.
  tableView.xs.footer = XSRefreshAutoNormalFooter(withRefreshing: self, action: #selector(loadMoreData))
}

@objc func refresh() {
  // Refreshing code...
  
  // End refreshing.
  tableView.xs.header?.endRefreshing()
}

@objc func loadMoreData() {
  // Load or refreshing Code...
  
  // End refreshing.
  if noMoreData {
    // No more data.
    tableView.xs.footer?.endRefreshingWithNoMoreData()
  } else {
    // End refreshing.
    tableView.xs.footer?.endRefreshing()
  }
}

Swift Chaining Grammar

func tableViewRefreshSetting() {
	XSRefreshNormalHeader { [weak self] in
		// Do something...
	}
	.autoChangeTransparency(true)
	.link(to: tableView)
  
  XSRefreshAutoNormalFooter { [weak self] in
		// Do something...
	}
	.autoChangeTransparency(true)
	.link(to: tableView)
}

Example Readmes

To see how the specification has been applied, see the example-readmes.

TODO List

  • Support for Carthage management tools
  • Support for Swift package management tools
  • Support horizontal scroll control, eg.CollectionView
  • Support Swift Chaining Grammar
  • ......

Maintainers

@XaoflySho.

License

MIT © Xaofly Sho