PullToRefreshSwift

iOS Simple Cool PullToRefresh Library. It is written in pure swift.

  • 所有者: dekatotoro/PullToRefreshSwift
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

PullToRefreshSwift

Platform
Language
License
Issues

iOS Simple PullToRefresh Library.

sample

##Installation

####CocoaPods

pod 'PullToRefreshSwift'

####Manually
Add the following files to your project.
pulltorefresharrow.png
PullToRefreshView.swift
PullToRefreshConst.swift
UIScrollViewExtension.swift

##Usage

###Setup

In your UIViewController Including UITableView, UICollectionView, UIScrollView:

  override func viewDidLoad() {
        self.tableView.addPullToRefresh({ [weak self] in
            // refresh code
            
            self?.tableView.reloadData()
            self?.tableView.stopPullToRefresh()
        })
  }

You can use PullToRefreshOption class at addPullToRefresh func option parameter:

  override func viewDidLoad() {
       let options = PullToRefreshOption()
        options.backgroundColor = UIColor.blueColor()
        options.indicatorColor = UIColor.whiteColor()
        
        self.tableView.addPullToRefresh(options: options, { [weak self] in
            // some code
            
            self?.tableView.reloadData()
            self?.tableView.stopPullToRefresh()
        })
        
  }

If you want to fixed pulltoRefreshView, please implement scrollViewDidScroll.

  func scrollViewDidScroll(scrollView: UIScrollView) {
    self.tableView.fixedPullToRefreshViewForDidScroll()
  }  

If you want to use the custom const, please change the PullToRefreshConst class.

struct PullToRefreshConst {
    static let tag = 810
    static let alpha = true
    static let height: CGFloat = 80
    static let imageName: String = "pulltorefresharrow.png"
    static let animationDuration: Double = 0.4
    static let fixedTop = true // PullToRefreshView fixed Top
}

If you want to use the custom option, please change the PullToRefreshOption class.
You can use this class at addPullToRefresh func option parameter.

class PullToRefreshOption {
    var backgroundColor = UIColor.clearColor()
    var indicatorColor = UIColor.grayColor()
    var autoStopTime: Double = 0.7 // 0 is not auto stop
    var fixedSectionHeader = false  // Update the content inset for fixed section headers
}

Requirements

Requires Swift3.0 and iOS 8.0 and ARC.
If you are developing in the Swift1.1 ~ 2.3, please use branch of Swift1.1 ~ Swift2.3.

Features

  • Highly customizable
  • Complete example
  • Refactoring

Contributing

Forks, patches and other feedback are welcome.

Creator

Yuji Hato
Blog

License

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

主要指標

概覽
名稱與所有者dekatotoro/PullToRefreshSwift
主編程語言Swift
編程語言Swift (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2014-12-11 10:08:57
推送於2019-05-11 11:01:02
最后一次提交2016-10-20 11:54:24
發布數8
最新版本名稱3.0.3 (發布於 )
第一版名稱1.0.0 (發布於 )
用户参与
星數536
關注者數20
派生數101
提交數82
已啟用問題?
問題數21
打開的問題數15
拉請求數8
打開的拉請求數9
關閉的拉請求數2
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?