iOS-Swift-MJRefresh 重写控件

2023-09-24 13 0

alt tag

GTMRefresh

github地址
简书地址

GTMRefresh 用Swift重写的MJRefresh

Introduction

  • 自定义方便, Demo里面有国内主流App的下拉效果的模仿
  • 代码简洁,总代码量不超过1000行
  • 支持国际化
  • 支持: UITableView, UICollectionView, UIScrollView, UIWebView

Demo

直接下载代码,里面Demo里面有各种效果的自定义效果(因为时间比较紧,demo代码可能不够漂亮)

alt tag

Demo模仿的下拉效果

  • YahooWeather
  • Curve Mask
  • Youku
  • TaoBao
  • QQ Video
  • DianPing
  • QQ

Installation

Cocoapods

Install Cocoapods if need be.

$ gem install cocoapods

Add GTMRefresh in your Podfile.

use_frameworks!pod 'GTMRefresh'

Then, run the following command.

$ pod install

Manual

Copy GTMRefresh folder to your project. That’s it.

Note: Make sure that all files in GTMRefresh included in Compile Sources in Build Phases.

版本

Vesrion 0.0.1

This version requires Xcode 8.0 and Swift 3.

使用帮助

Firstly, import GTMRefresh.

import GTMRefresh

使用默认的下拉和上拉效果

    self.tableView.gtm_addRefreshHeaderView {[weak self] inprint("excute refreshBlock")self.refresh()}self.tableView.gtm_addLoadMoreFooterView {[weak self] inprint("excute loadMoreBlock")self.loadMore()}

代码触发刷新

    self.tableView.triggerRefreshing()

自定义下拉刷新效果

约定
- 必须继承 GTMRefreshHeader
- 必须实现 SubGTMRefreshHeaderProtocol

SubGTMRefreshHeaderProtocol

public protocol SubGTMRefreshHeaderProtocol {/// 状态变成.idlefunc toNormalState()/// 状态变成.refreshingfunc toRefreshingState()/// 状态变成.pullingfunc toPullingState()/// 状态变成.willRefreshfunc toWillRefreshState()/// 下拉高度/触发高度 值改变func changePullingPercent(percent: CGFloat)/// 开始结束动画前执行func willBeginEndRefershing(isSuccess: Bool)
代码编程
赞赏

相关文章

外贸企业邮箱注册哪个好?怎么申请企业邮箱,两步轻松完成
外贸行业等公司企业邮箱不可替代的重要性
最走心的商务邮箱有哪些,如何拥有一个与众不同的电子邮箱!
初入职场的你知道如何向领导邮件汇报工作吗
邮件误删恢复,一个功能强大的企业邮箱
公司企业邮箱怎么选择?哪家企业邮箱品牌最好用?