NoveCircularProgressBar 1.0.0

NoveCircularProgressBar 1.0.0

Steve Gigou 维护。



NoveCircularProgressBar

Version License Platform

为您的 iOS 项目的 Swift 创建一个动画环形进度条。

特性

Animated circular progress bar

  • 完整动画进度条。
  • 可以在 Interface Builder 中使用和自定义。
  • 自定义颜色、动画持续时间和大小。
  • 自定义边框大小以配合更大或更小的显示。
  • 已进行单元测试。

要求

  • iOS 9.0+

安装

NoveCircularProgressBar 使用 CocoaPods。它是 Cocoa 项目的依赖管理器。

要使用 CocoaPods 将 NoveCircularProgressBar 集成到您的 Xcode 项目中,请在 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'NoveCircularProgressBar', '~> 1.0'

然后,运行以下命令

$ pod install

使用

创建一个新的实例

在Interface Builder中,您可以将UIView添加到界面中,并将自定义类设置为NoveCircularProgressBar

NoveCircularProgressBar custom class in Interface Builder

您也可以通过编程方式创建进度条。要这样做,只需导入模块,并使用以下初始化器

import NoveCircularProgressBar

let progressBar = NoveCircularProgressBar(frame: CGRect(x: 0, y: 0, width: 24, height:  24))

然后,将进度条添加到其父级别

parentView.addSubview(progressBar)

配置

进度条由静态边框和动画进度条组成。

NoveCircularProgressBar structure

NoveCircularProgressBar可根据您的应用需求进行调整。您可以调整以下设置

  • color将改变进度条及其边框的颜色。
  • speed表示进度条从0.0到1.0的动画时长。
  • lineWidth代表边框厚度和边框与进度条之间的空间。

您可以在Interface Builder中设置这些属性

bar_configuration

或者在您的进度条实例化后以编程方式设置

progressBar.lineWidth = 2.0
progressBar.color = .systemBlue
progressBar.speed = 1.0

百分比更新

您的进度条创建并配置好后,可以通过调用以下方法来更新显示的百分比

progressBar.updateProgress(to: percentage, animated: true)

以下参数为

  • to是新要显示的百分比(介于0.0和1.0之间),
  • animated指示组件播放动画或将组件跳转到目标位置。

致谢

Steve Gigou (Website, Twitter)

许可证

NoveCircularProgressBar在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。