测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017年8月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 micazeve 维护。
MAGearRefreshControl 是一个完全可定制的 iOS 刷新控件,适用于 tableview 刷新,由 Swift 编写,具有齿轮动画。
##2017年2月20日编辑:
此组件现在兼容 Swift 3.0。仍然可用 swift-2.0
分支。
##2015年11月16日编辑:
添加了一个新枚举 MAGearStyle
,以便在齿轮组内自定义单个齿轮。
.Normal
:全套齿轮,您从一开始就知道的那个 :).Branched
:具有分支的齿轮。由于难以描述,所以附上一张图片会更加直观。现在您可以轻松地添加自己的齿轮样式,我愿意合并它们。
##2015年6月23日编辑:
添加了一个中间类 MAAnimatedMultiGearView
,以便可以在不需要使用 MAGearRefreshControl
对象的情况下进行旋转动画。
##致谢:
本项目受以下 Dribbble 帖子 的启发。刷新控件的主体结构基于 EGOTableViewPullRefresh。
##如何使用:
###内容:### MAGearRefreshControl 由五个基本类组成,您可以根据需要进行使用
UIView
子类,用于绘制齿轮。UIView
子类,用于绘制多个齿轮。MAMultiGearView
子类,用于绘制和动画多个齿轮。MAAnimatedMultiGearView
子类,用于绘制多个齿轮,并提供与 UIRefreshControl
相同的交互。###刷新控件###
必须从 UITableViewController
子类或具有 UITableView
的 UIViewController
子类中使用 MAGearRefreshControl
。已提供两种情况的示例。
refreshControl = MAGearRefreshControl(frame: CGRect(x: 0, y: -self.myTableView.bounds.height, width: self.view.frame.width, height: self.myTableView.bounds.height))
refreshControl.backgroundColor = UIColor.initRGB(34, g: 75, b: 150)
_ = refreshControl.addInitialGear(nbTeeth:12, color: UIColor.initRGB(92, g: 133, b: 236), radius:16)
refreshControl.delegate = self
self.tableView.addSubview(refreshControl)
您可以使用一个单一的方法轻松添加新的齿轮
_ = refreshControl.addLinkedGear(0, nbTeeth:16, color: UIColor.blue, angleInDegree: 30)
_ = refreshControl.addLinkedGear(0, nbTeeth:32, color: UIColor.red, angleInDegree: 190)
// Gear with branch style :
refreshControl.addLinkedGear(1, nbTeeth:14, color: yellowColor(), angleInDegree: 20, gearStyle: .WithBranchs)
// Gear with branch style and custom number of branchs:
refreshControl.addLinkedGear(1, nbTeeth:45, color: greenColor(), angleInDegree: -50, gearStyle: .WithBranchs, nbBranches:12))
现在,您必须遵守 MAGearRefreshDelegate
协议
// Method called to know if the data source is loading or no
func MAGearRefreshTableHeaderDataSourceIsLoading(_ view: MAGearRefreshControl) -> Bool {
return isLoading
}
// Method called when the pull to refresh move was triggered.
func MAGearRefreshTableHeaderDidTriggerRefresh(_ view: MAGearRefreshControl) {
refresh()
}
刷新控件必须通过 MAGearRefreshScrollViewDidEndDragging
、MAGear RefreshScrollViewDidScroll
和 MAGearRefreshScrollViewDataSourceDidFinishedLoading
方法来通知滚动事件和请求数据时。示例项目说明了何时调用这些方法。
##许可证:
MAGearRefreshControl受MIT许可证的约束,因此您可以按照自己的意愿使用/修改它。任何反馈都受到感激。
##联系方式: