RappleProgressHUD 4.1

RappleProgressHUD 4.1

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

Rapple UI Animator 维护。



  • 作者
  • Rajeev Prasad

RappleProgressHUD

Version License Platform

Swift 5 的用户友好、易于使用的活动/进度指示视图

对于 Swift v5.0 使用最新 pod 版本(4.x)

对于 Swift v4.2 使用 pod 版本 3.0.4

对于 Swift v4.0 使用 pod 版本 2.4.1

演示

demo

最新Pod要求

  • Swift 5
  • Xcode 11
  • iOS 10+

安装

Cocoapods

RappleProgressHUD可以通过CocoaPods访问。要安装它,在你的Podfile中添加以下行

pod "RappleProgressHUD" 

Swift Package Manager

RappleProgressHUD也可以通过Swift Package Manager获得。要安装它,将以下git链接添加到Swift Package Manager中

https://github.com/rjeprasad/RappleProgressHUD.git

用法

然后简单地导入RappleProgressHUD

import RappleProgressHUD

可以使用以下提到的任何启动方法启动RappleActivityIndicatorView。调用这些启动方法时,可以使用两个基本可选输入值来自定义UI。

label 这是你将显示在活动指标中的文本值

attributes 这是一个字典,具有以下键。

  • RappleTintColorKey 进度圈和文本的颜色
  • RappleScreenBGColorKey 背景颜色(全屏背景)
  • RappleProgressBGColorKey 进度指标周围的背景颜色(仅适用于Apple样式)
  • RappleIndicatorStyleKey ActivityIndicator的样式 - 有关细节,请参阅以下部分
  • RappleProgressBarColorKey 进度条背景颜色 - 轨道背景颜色
  • RappleProgressBarFillColorKey 进度条填充颜色,用于进度的显示 - 填充轨道颜色
  • RappleIndicatorThicknessKey ActivityIndicator的厚度(宽度) - 针对'RappleStyleCircle'和完成指标适用

在上面的字典中,你可以传递以下三个样式的'RappleIndicatorStyleKey'(有关更多详细信息,请查看演示)

  • RappleStyleApple 默认苹果样式 ActivityIndicator
  • RappleStyleCircle 自定义圆形 ActivityIndicator
  • RappleStyleText 自定义文本 ActivityIndicator(例如:加载.. | 加载....)

RappleActivityIndicatorView 提供了两个预设属性集,便于使用

RappleAppleAttributes 预定义属性字典以匹配默认苹果外观和 feel

  • RappleTintColorKey 白色
  • RappleScreenBGColorKey 白色:0.0, alpha:0.2
  • RappleProgressBGColorKey 白色:0.0, alpha:0.7
  • RappleIndicatorStyleKey RappleStyleApple
  • RappleProgressBarColorKey 浅灰色
  • RappleProgressBarFillColorKey 白色
  • RappleIndicatorThicknessKey 4.0

RappleModernAttributes 预定义的具有现代外观和 feel 的属性字典

  • RappleTintColorKey 白色
  • RappleScreenBGColorKey 白色:0.0, alpha:0.5
  • RappleProgressBGColorKey N/A
  • RappleIndicatorStyleKey RappleStyleCircle
  • RappleProgressBarColorKey 浅灰色
  • RappleProgressBarFillColorKey 白色
  • RappleIndicatorThicknessKey 4.0

RappleTextAttributes 预定义的具有现代外观和 feel 的属性字典

  • RappleTintColorKey 白色
  • RappleScreenBGColorKey 白色:0.0, alpha:0.5
  • RappleProgressBGColorKey N/A
  • RappleIndicatorStyleKey RappleStyleText
  • RappleProgressBarColorKey N/A
  • RappleProgressBarFillColorKey N/A
  • RappleIndicatorThicknessKey 4.0

或者您可以发送任何带有这些 Key 值的自定义字典来自定义外观和 feel

要创建自定义属性字典,您可以使用以下方法,并且该方法的这些参数都具有默认值。

let attributes = RappleActivityIndicatorView.attribute(style: RappleStyle.apple, tintColor: .yellow, screenBG: .purple, progressBG: .black, progressBarBG: .orange, progreeBarFill: .red, thickness: 4)

let attributes = RappleActivityIndicatorView.attribute(style: RappleStyle.apple, tintColor: .yellow, progreeBarFill: .red, thickness: 2)

RappleActivityIndicatorView 启动方法

使用 RappleModernAttributes 开始 RappleActivityIndicatorView - 没有文本消息

RappleActivityIndicatorView.startAnimating()

使用自定义(或预定义)属性开始 RappleActivityIndicatorView - 没有文本消息

RappleActivityIndicatorView.startAnimating(attributes: RappleModernAttributes)

使用文本消息、使用 RappleModernAttributes 开始 RappleActivityIndicatorView

RappleActivityIndicatorView.startAnimatingWithLabel("Processing...")

使用文本消息和属性开始 RappleActivityIndicatorView

RappleActivityIndicatorView.startAnimatingWithLabel("Processing...", attributes: RappleModernAttributes)

停止 RappleActivityIndicatorView

RappleActivityIndicatorView.stopAnimating()

RappleActivityIndicatorView 还可以通过完成指示器来关闭

RappleActivityIndicatorView.stopAnimation(completionIndicator: .success, completionLabel: "Completed.", completionTimeout: 1.0)

您可以使用以下任意的 RappleCompletion 枚举值作为指示器

  • none 停止并隐藏动画,没有完成指示器
  • success ✓ 符号
  • failed ✕ 符号
  • incomplete ! 符号
  • unknown ? 符号

开始 RappleActivityIndicatorView 的进度值

  • 进度量 0<= 进度 <= 1.0
  • 文本进度量值(例如 "3/8""3/10"): 预留空间有限
  • textValue nil 将显示百分比值(例如 78%)
  • textValue "" 转换为 -> 隐藏文本进度量
  • RappleStyleApple 将使用默认的苹果进度条
  • RappleStyleCircle 将使用环形进度条
  • RappleStyleText 将不显示任何进度条
RappleActivityIndicatorView.setProgress(0.2, textValue: "1/5")
RappleActivityIndicatorView.setProgress(0.2) // Display with percentage value

如何添加进度条

首先使用任意的启动方法开始进度条
然后调用带有或不带 textValue: 参数的 setProgress 方法

RappleActivityIndicatorView.startAnimatingWithLabel("Processing...")
RappleActivityIndicatorView.setProgress(0.2, textValue: "1/5")

然后逐渐增加相应的进度值 - 可从任何线程调用

RappleActivityIndicatorView.setProgress(0.4, textValue: "2/5")

检查 RappleActivityIndicatorView 的可见性

RappleActivityIndicatorView.isVisible()

示例项目

要运行示例项目,请先克隆存储库,然后从示例目录运行 pod install

作者

拉贾夫·普拉萨德,[email protected]

许可

MIT许可协议(MIT)

版权所有(c)2015-2019 拉贾夫·普拉萨德 [email protected]

以下是对所有获取本软件及其相关文档副本(“软件”)的个人或单位的许可,免费地允许此类个人或单位在不作限制的情况下处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、许可和/或出售软件副本的权限,并允许向软件提供者提供此类软件的个人使用上述行为,前提是遵守以下条件:

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“现状”提供,不提供任何形式的明示或暗示担保,包括但不限于适销性、适用于特定目的和无侵犯担保。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论此类索赔、损害或其他责任是由于合同、侵权或其他行为的责任,还是与软件或对软件的使用或任何其他方式有关。