UICircleProgressView 0.6.1

UICircleProgressView 0.6.1

维护者:Richard Weinhold.




  • Richard Weinhold

CircleProgressView

Version License Platform

一个精简的类似于AppStore下载进度圆形指示器视图。

所有图形都只使用CAShapeLayerUIBezierPath完成,并使用CAAnimation进行动画处理。因此不需要额外的资源,所有方面均可自定义。

预览旧风格

预览新风格

安装

UICircleProgressView通过CocoaPods提供。要安装它,请简单地将以下行添加到您的Podfile中

pod 'UICircleProgressView'

示例

使用以下任一方法

  • Interface-Builder创建一个UIView并将其基类设置为UICircleProgressView
  • 在源代码中创建一个UICircleProgressView
import UICircleProgressView

let progressView = UICircleProgressView(frame: CGRect(x: 0, y: 0, width: 24, height: 24), style: .new, status: .waiting)
progressView.tintColor = .blue

// starting download...
progressView.status = .downloading

for progress in stride(from: 0.0, to: 1.0, by: 0.01) {
    progressView.progress = CGFloat(progress)
    usleep(20000)
}
progressView.status = .success

有关完整示例项目,请参阅:example.xcodeproj或直接查看ViewController.swift

使用说明

以下属性用于自定义和控制进度视图

属性 行为 类型 / 值
状态 当前的进度状态 enum: DownloadStatus
[.paused,.waiting,
.downloading,.success,
.canceled]
样式 进度视图的UI样式 enum: StyleType
[.old,.new]
进度 当前的进度 Float (0.0 - 1.0)
strokeWidth 显式设置进度圆的笔画宽度 CGFloat
strokeDynamic 使用以下之一:为进度圆的笔画提供一个显式的strokeWidth值,或动态计算它 Bool
colorSuccess/
colorPaused/
colorCanceled/
tintColor
设置进度颜色 UIColor

所有这些属性也可以在XCode-Interfacebuilder中设置,多亏了@IBDesignable

按钮

此库还提供圆形进度条的按钮版本,以模仿AppStore下载按钮。用法与进度视图基本相同,只需使用UICircleProgressButton

除了所述的进度视图属性外,按钮还支持

属性 行为 类型 / 值
startImage 当进度停止时应该显示的按钮图片视图 UIImage?
stopImage 当进度正在下载/等待时应该显示的按钮图片视图 UIImage?

许可证

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