RPCircularProgress
使用 Swift 编写的 UIView 子类来显示环形进度。
您的应用程序正在使用它吗?让我知道!
请参阅附带的应用示例以获取使用示例。
样式
- 不确定(无限旋转)
- 普通(设置进度在 0.0 到 1.0 之间)
- 混合(可以设置为不确定,但也可以将进度动画到 1.0)
公共 API
/**
Enables or disables the indeterminate (spinning) animation
- parameter enabled: Whether or not to enable the animation (defaults to `true`)
- parameter completion: An optional closure to execute after the animation completes
*/
open func enableIndeterminate(_ enabled: Bool = true, completion: CompletionBlock? = nil) {}
/**
Updates the progress bar to the given value with the optional properties
- parameter progress: The progress to update to, pinned between `0` and `1`
- parameter animated: Whether or not the update should be animated (defaults to `true`)
- parameter initialDelay: Sets an initial delay before the animation begins
- parameter duration: Sets the overal duration that the animation should complete within
- parameter completion: An optional closure to execute after the animation completes
*/
open func updateProgress(_ progress: CGFloat, animated: Bool = true, initialDelay: CFTimeInterval = 0, duration: CFTimeInterval? = nil, completion: CompletionBlock? = nil) {}
属性
注意:以下大多数属性都是 @IBInspectable
,但我个人并不使用 Interface Builder,如果有任何问题请告诉我。
var trackTintColor: UIColor
- 空白进度条的颜色(被绘制在其上)
var progressTintColor: UIColor
- 进度条的颜色
var innerTintColor: UIColor?
- 进度区域内刻出的圆圈的颜色(如果有的话)
var roundedCorners: Bool
- 设置进度条的角落是否应该圆形
var thicknessRatio: CGFloat
- 设置进度条应该多厚(固定在
0.01
和1
之间)
var clockwiseProgress: Bool
- 设置动画是否应该顺时针进行
var timingFunction: CAMediaTimingFunction
- 定义动画速度的定时函数。默认为“加减速”动画
var progress: CGFloat
- 当前进度的获取器(不被任何活动动画观察)
var indeterminateProgress: CGFloat
- 设置在不确定的动画中进度条应填充多少,固定在
0.05
和0.9
之间 - 注意: 可以通过使用
updateProgress(...)
覆盖/动画
var indeterminateDuration: CFTimeInterval
- 控制不确定进度条动画的速度
支持
Swift, ARC & iOS 8+, 自动布局或弹簧和拉杆
我的朋友们给我一点帮助
请随意fork并提交修复错误或改进的pull请求,确保保持一般的编码风格,添加测试,并在需要时添加注释。
鸣谢
这个库实际上是DACircularProgress的Swift版,对API做了一些小的改变,因此应该可以作为其替代品。我真的很喜欢那个库,但不幸的是它没有被维护。