{"id":18695545,"url":"https://github.com/targetcloud/tgrefreshswift","last_synced_at":"2025-04-12T07:25:41.540Z","repository":{"id":56922880,"uuid":"95259521","full_name":"targetcloud/TGRefreshSwift","owner":"targetcloud","description":"弹簧、橡皮筋下拉刷新控件，类似QQ下拉刷新效果，同时支持其他样式","archived":false,"fork":false,"pushed_at":"2017-08-15T23:59:25.000Z","size":11668,"stargazers_count":50,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-21T07:03:44.374Z","etag":null,"topics":["elastic","indicator","refresh"],"latest_commit_sha":null,"homepage":"https://github.com/targetcloud/TGRefreshSwift","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/targetcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-23T22:00:36.000Z","updated_at":"2021-03-20T03:16:06.000Z","dependencies_parsed_at":"2022-08-21T04:50:26.721Z","dependency_job_id":null,"html_url":"https://github.com/targetcloud/TGRefreshSwift","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/targetcloud%2FTGRefreshSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/targetcloud%2FTGRefreshSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/targetcloud%2FTGRefreshSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/targetcloud%2FTGRefreshSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/targetcloud","download_url":"https://codeload.github.com/targetcloud/TGRefreshSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248532398,"owners_count":21119902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elastic","indicator","refresh"],"created_at":"2024-11-07T11:15:26.061Z","updated_at":"2025-04-12T07:25:41.517Z","avatar_url":"https://github.com/targetcloud.png","language":"Swift","readme":"\u003cimg src=\"https://github.com/targetcloud/TGRefreshSwift/blob/master/Banners.png\" width = \"12%\" hight = \"12%\"/\u003e\n\n  ## TGRefreshSwift\n下拉刷新控件，含弹簧、橡皮筋样式（类似QQ下拉刷新控件，但比QQ 更强），同时支持其他样式，可DIY刷新前中后各状态下的动画...\n\n![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg)\n![Build](https://img.shields.io/badge/build-passing-green.svg)\n![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)\n![Platform](https://img.shields.io/cocoapods/p/Pastel.svg?style=flat)\n![Cocoapod](https://img.shields.io/badge/pod-v0.0.6-blue.svg)\n\n\n## OC Version\nhttps://github.com/targetcloud/TGRefreshOC\n\n\n## Recently Updated\n- 0.0.6 加入了刷新前动画样式选择，目前共支持刷新前、刷新中、刷新后的失败或成功4种状态下的动画特效，全网最强\n- 0.0.5 删除了成功和失败时的指示图标，全部换成了指示动画，支持刷新成功和失败时分别设置动画类型和颜色，系统指示器也换成自定义指示器，共三种状态指示器供设置，动画类型也多达35种，配置参数目前支持27个\n- 0.0.4 增加了稳定性\n- 0.0.1 TGRefreshOC版本的增强版本，更多参数配置\n\n\n## Features\n- [x] 支持刷新前、中、后各种状态时的动画特效设置，DIY你满意的一款\n- [x] 支持链式编程配置，程序员的最爱\n- [x] 支持两种刷新结果提示\n- [x] 支持QQ和Common两种下拉刷新样式\n- [x] 支持contentInset\n- [x] 支持Cocoapods\n- [x] 支持MJRefresh到TGRefresh风格切换，只需要把mj_header改为tg_header，改动2个字母即可\n- [x] 支持4种配置方式，Ordinary、Simple、Senior、Recommend，推荐使用Recommend配置\n- [x] 支持刷新结果回显配置\n- [x] 支持刷新结果成功或失败配置\n- [x] 超轻量级、使用超灵活、功能超强大\n- [x] 用例丰富，快速上手\n\n\n## Usage\n\n#### 以下tv均指tableview或UIScrollview类型\n\n首先写上这一句\n```swift\nimport TGRefreshSwift\n```\n如果需要，在你的控制器中加上一句\n```swift\nself.automaticallyAdjustsScrollViewInsets=false\n```\n\n#### QQ效果(常用、一句话)\n```swift\nself.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior))\n```\n\n#### 普通效果\n```swift\nself.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior)){(refresh) in\n            refresh.tg_kind(.Common)\n        }\n```\n\n#### 更多配置，使用链式编程配置\n```swift\n    self.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior)){(refresh) in\n            refresh.tg_refreshResultBgColor(UIColor.orange.withAlphaComponent(0.8))\n                .tg_kind(.Common)\n                .tg_tinColor(UIColor.green)\n                .tg_fadeinTime(1)\n                .tg_fadeoutTime(0.5)\n                .tg_verticalAlignment(.Midden)\n                .tg_indicatorRefreshingStyle(.lineCursor)\n                .tg_indicatorNormalStyle(.lineOrderbyAsc)\n                .tg_bgColor(UIColor(white:1,alpha:1))\n        }\n```\n\n#### 扩展用法\n除了传入数据加载事件、配置信息外，还可以传入刷新控件的初始高度（默认40）与背景图\n```swift\nself.tv.tg_header = TGRefreshSwift.refresh(self, #selector(loadDataSenior),\n44,\nUIImageView(image: UIImage(named: \"profile_cover_background\")) \n){(refresh) in\n            refresh.tg_refreshResultBgColor(UIColor.orange.withAlphaComponent(0.8))\n                .tg_verticalAlignment(.Midden)\n                .tg_tinColor(UIColor.white)\n                .tg_tipLabelFontSize(12)\n                .tg_resultLabelFontSize(13)\n                .tg_tipFailStyle(.ballScale)\n                .tg_tipOKStyle(.ballScale)\n                .tg_indicatorRefreshingStyle(.orbit)\n                .tg_fadeinTime(1)\n                .tg_fadeoutTime(0.5)\n                .tg_bgColor(UIColor(white:0.5,alpha:1))\n        }\n```\n\n#### 开始刷新\n```swift\nself.tv.tg_header?.beginRefreshing()\n```\n\n#### （网络请求等情况得到数据后）结束刷新\n```swift\nself.tv.tg_header?.endRefreshing()\n```\n\n#### 结束刷新时的回显\n```swift\n//示例代码\nDispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+2) {\n            let isSuccess = arc4random_uniform(3) % 2 == 0\n            let count = isSuccess ? arc4random_uniform(20)+1 : 0\n            self.dataCount = count\u003e0 ? Int(count) : self.dataCount\n            self.tv.tg_header?.refreshResultStr = count\u003e0 ? \"成功刷新到\\(count)条数据,来自TGRefreshSwift\" : \"请先在Github上Star本控件:-）\"\n            self.tv.tg_header?.isSuccess = isSuccess\n            isSuccess ? self.tv.reloadData() : ()\n            self.tv.tg_header?.endRefreshing()\n        }\n```\n\n#### 可以配置的属性（共28个）\n``` swift\n/** 刷新中的指示器类型 */\npublic var indicatorRefreshingStyle: TGIndicatorType = .lineCursor\n    \n/** 刷新前的指示器类型 */\npublic var indicatorNormalStyle: TGIndicatorType = .lineOrderbyAsc\n    \n/** 刷新失败时的提示器样式 */\npublic var tipFailStyle: TGIndicatorType = .ballScaleMultiple\n    \n/** 刷新失败时的提示器颜色 */\npublic var tipFailColor: UIColor = .red\n    \n/** 刷新成功时的提示器样式 */\npublic var tipOKStyle: TGIndicatorType = .ballScaleMultiple\n    \n/** 刷新成功时的提示器颜色 */\npublic var tipOKColor: UIColor = .green\n    \n/** 忽略初始的InsetTop,用于刷新控件所画的位置进行定位 */\npublic var ignoreScrollViewContentInsetTop: Bool = false\n    \n/** 各元素间边界 */\npublic var margin: CGFloat = 10\n    \n/** 类型，默认为QQ弹簧 皮筋效果 */\npublic var kind: TGRefreshKind = .QQ\n    \n/** 主题色（状态提示文字颜色（不包含结果提示）、ActivityIndicator颜色、橡皮筯颜色） */\npublic var tinColor : UIColor = .gray\n    \n/** 背景色 */\npublic var bgColor: UIColor?\n\n/** 垂直对齐，默认顶部 */\npublic var verticalAlignment: TGRefreshAlignment = .Top\n    \n/** 是否显示刷新成功或失败 */\npublic var isShowSuccesOrFailInfo: Bool = true\n    \n/** 是否刷新成功 在第二次刷新前自动置为true */\npublic var isSuccess: Bool = true\n    \n/** 刷新失败时的提示文字 */\npublic var refreshFailStr: String = \"刷新失败\"\n    \n/** 刷新成功时的提示文字 */\npublic var refreshSuccessStr: String = \"刷新成功\" \n    \n/** 准备刷新时的提示文字 */\npublic var refreshNormalStr: String = \"下拉可以刷新\"\n    \n/** 即将刷新时的提示文字 */\npublic var refreshPullingStr: String = \"松开立即刷新\"\n    \n/** 正在刷新时的提示文字 */\npublic var refreshingStr: String = \"正在刷新数据中...\"\n    \n/** 更新结果的回显文字 */\npublic var refreshResultStr: String = \"\"\n    \n/** 更新结果的回显背景色 */\npublic var refreshResultBgColor: UIColor = UIColor.gray.withAlphaComponent(0.8)\n    \n/** 更新结果的回显文字颜色 */\npublic var refreshResultTextColor: UIColor = .white\n    \n/** 更新结果的回显高度 */\npublic var refreshResultHeight: CGFloat = 34\n    \n/** 自动改变透明度，默认已做优化 */\npublic var automaticallyChangeAlpha: Bool = false\n    \n/** 回显时的渐显时间 0.1 ～ 2秒 默认0.5 */\npublic var fadeinTime: CGFloat = 0.5\n    \n/** 回显时的渐隐时间 0.1 ～ 5秒 默认1.5 */\npublic var fadeoutTime: CGFloat = 1.5\n    \n/** 提示文字字体大小 9 ～ 20 默认11 */\npublic var tipLabelFontSize: CGFloat = 11\n    \n/** 结果文字字体大小 9 ～ 20 默认12 */\npublic var resultLabelFontSize: CGFloat = 12\n\n\nTGIndicatorType可供选择的动画类型有\n.ballPulse\n.ballGridPulse\n.ballClipRotate\n.squareSpin\n.ballClipRotatePulse\n.ballClipRotateMultiple\n.ballPulseRise\n.ballRotate\n.cubeTransition\n.ballZigZag\n.ballZigZagDeflect\n.ballTrianglePath\n.ballScale\n.lineScale\n.lineScaleParty\n.ballScaleMultiple\n.ballPulseSync\n.ballBeat\n.lineScalePulseOut\n.lineScalePulseOutRapid\n.ballScaleRipple\n.ballScaleRippleMultiple\n.ballSpinFadeLoader\n.lineSpinFadeLoader\n.triangleSkewSpin\n.pacman\n.ballGridBeat\n.semiCircleSpin\n.ballRotateChase\n.orbit\n.lineCursor\n.squareGridPulse\n.squarePulse\n.windows\n.lineOrderbyAsc\n.audioEqualizer\n\n```\n#### 使用链式编程配置时，请在所有属性前加tg_前缀即可\n\n### 更多使用配置组合效果请download本项目或fork本项目查看\n\n## 运行效果\n![](https://github.com/targetcloud/TGRefreshSwift/blob/master/a.gif) \n\n\n## demo中的弹簧效果\n![](https://github.com/targetcloud/TGRefreshSwift/blob/master/c.gif) \n\n\n## Installation\n- 下载并拖动TGRefreshSwift到你的工程中\n\n- Cocoapods\n```\npod 'TGRefreshSwift'\n```\n\n## Reference\n- http://blog.csdn.net/callzjy\n- https://github.com/targetcloud/baisibudejie\n- https://github.com/targetcloud/TGLabel \u003cimg src=\"https://github.com/targetcloud/TGLabel/blob/master/Banners.png\" width = \"8%\" hight = \"8%\"/\u003e\n- https://github.com/targetcloud/TGImage \u003cimg src=\"https://github.com/targetcloud/TGImage/blob/master/snapShot/Banners.png\" width = \"12%\" hight = \"12%\"/\u003e\n\n如果你觉得赞，请Star\n\n\u003cimg src=\"https://github.com/targetcloud/TGRefreshSwift/blob/master/logo.png\" width = \"12%\" hight = \"12%\"/\u003e\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftargetcloud%2Ftgrefreshswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftargetcloud%2Ftgrefreshswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftargetcloud%2Ftgrefreshswift/lists"}