Latest 0.2.0
Homepage https://github.com/Detailscool/YHRefresh
License MIT
Platforms ios 8.0, requires ARC
Authors

Version
license
Platform
Language

Introduction

Inspired By MJRefresh

A refreshing helper written in Swift, which can be used to refresh easily.Still working on making it more perfectly.Looking forward to any positive suggestion
Swift 3.1 Supporting Now…
一款简单易用的Swift版上拉或者下拉刷新…还在努力不断完善中…欢迎任何建设性PR
现已支持Swift 3.1

Components

Cocoapods

edit Podfile 编辑Podfile文件:

  use_frameworks!
  pod 'YHRefresh', '~> 0.2.0’

then run in terminal 在终端运行:

  pod install --no-repo-update

Usage

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.yh_header = YHRefreshNormalHeader.header(self, selector: "load") as! YHRefreshNormalHeader
    tableView.yh_header.beginRefreshing()
}

func load() {

    //模拟网络请求
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), { () -> Void in

      /*网络回调处理*/

      /*刷新数据*/
      self.tableView.reloadData()
      /*结束刷新*/
      self.tableView.yh_header?.endRefreshing()

    }
}

-----------------------------------分割线-----------------------------------
override func viewDidLoad() {
    super.viewDidLoad()

    tableView.yh_footer = YHRefreshNormalFooter.footer(self, selector: "loadMore") as! YHRefreshNormalFooter

}

func loadMore() {

    //模拟网络请求
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), { () -> Void in

      /*网络回调处理*/

      /*刷新数据*/
      self.tableView.reloadData()
      /*结束刷新*/
      self.tableView.yh_footer?.endRefreshing()

      /*条件判断是否已经数据最大,若是显示没有更多数据*/
      //self.tableView.yh_footer?.showNoMoreData()

    }
}
-----------------------------------分割线-----------------------------------
注:header和footer可以同时用,但请回避两者同时刷新~!

Effect

①YHRefreshNormalHeader

②YHRefreshSpringHeader

③YHRefreshGifHeader

④YHRefreshNormalFooter

⑤YHRefreshAutoFooter

⑥YHRefreshGifFooter

Requirements

  • Swift 3.1
  • Xcode 8.0++

License

Copyright (c) 2016 YuanHui Lee [email protected] See the LICENSE file for more info.

Latest podspec

{
    "name": "YHRefresh",
    "version": "0.2.0",
    "summary": "A Refresh Framework Written In Swift.",
    "homepage": "https://github.com/Detailscool/YHRefresh",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Detailscool": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Detailscool/YHRefresh.git",
        "tag": "0.2.0"
    },
    "social_media_url": "http://www.jianshu.com/u/5a65c3921bda",
    "source_files": "YHRefresh/*.swift",
    "resources": "YHRefresh/YHRefresh.bundle",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This