iOS-Swift-MJRefresh 重写控件

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] in
        print("excute refreshBlock")
        self.refresh()
    }

    self.tableView.gtm_addLoadMoreFooterView {
        [weak self] in
        print("excute loadMoreBlock")
        self.loadMore()
    }

代码触发刷新

    self.tableView.triggerRefreshing()

自定义下拉刷新效果

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

SubGTMRefreshHeaderProtocol

public protocol SubGTMRefreshHeaderProtocol {
    /// 状态变成.idle
    func toNormalState()
    /// 状态变成.refreshing
    func toRefreshingState()
    /// 状态变成.pulling
    func toPullingState()
    /// 状态变成.willRefresh
    func toWillRefreshState()
    /// 下拉高度/触发高度 值改变
    func changePullingPercent(percent: CGFloat)
    /// 开始结束动画前执行
    func willBeginEndRefershing(isSuccess: Bool
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值