SwiftPullToRefresh 3.1.1

SwiftPullToRefresh 3.1.1

测试测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2019年10月
SPM支持 SPM

Leo Zhou 维护。



  • Leo Zhou

Logo

Build Status Carthage compatible CocoaPods Compatible Platform Language License codebeat badge

SwiftPullToRefresh

一种简单的方法,通过基于UIScrollView的扩展实现基于Swift 4的拉取刷新功能。

提供默认样式的头部和尾部控件,您可以直接在项目中使用,同时也支持自定义。还支持GIF图片。

示例用法

指示器头部

scrollView.spr_setIndicatorHeader { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

文本头部

scrollView.spr_setTextHeader { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

小型GIF标题

scrollView.spr_setGIFHeader(data: data, isBig: false, height: 60) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

GIF加文本标题

scrollView.spr_setGIFTextHeader(data: data) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

大型GIF标题

scrollView.spr_setGIFHeader(data: data, isBig: true, height: 120) { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

指示器页脚

scrollView.spr_setIndicatorFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

scrollView.spr_setIndicatorAutoFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

文本页脚

scrollView.spr_setTextFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

scrollView.spr_setTextAutoFooter { [weak self] in
    // do your action here
    // self?.scrollView.spr_endRefreshing()
}

清除标题或页脚

scrollView.spr_clearHeader()
scrollView.spr_clearFooter()

演示

在Xcode中打开并运行SwiftPullToRefreshDemo目标,以查看SwiftPullToRefresh的更多操作。

需求

  • iOS 8.0
  • Swift 4.0

安装

CocoaPods

use_frameworks!
pod 'SwiftPullToRefresh'

Carthage

github "WXGBridgeQ/SwiftPullToRefresh"

手动

将SwiftPullToRefresh文件夹添加到你的项目中。

定制

该框架非常容易定制使用。

你只需要继承RefreshView并实现以下方法,然后使用你的scrollView调用spr_setCustomHeader(_:)spr_setCustomFooter(_:)

class CustomHeaderOrFooter: RefreshView {
    override func didUpdateState(_ isRefreshing: Bool) {
        // customize your view display with refresh state here
    }
    
    override func didUpdateProgress(_ progress: CGFloat) {
        // customize your view display with progress here
    }
}

你还可以查看SwiftPullToRefreshDemo目标(灵感来自RayWenderlich)中超猫刷新的代码。

贡献

欢迎您通过 Fork 仓库,修改代码并提交问题或拉取请求来为项目做出贡献。

许可

基于 MIT 许可证提供。更多信息请参阅 LICENSE 文件。