KYCircularProgress
用 Swift 编写的灵活进度条。
功能
- 渐变颜色
- 进度闭包
- UIBezierPath 进度条
- 进度表盘指南
- 在 Storyboard 上可定制
- 进度变化动画
演示
要求
- Swift4
用法
创建 KYCircularProgress
// create KYCircularProgress
let circularProgress = KYCircularProgress(frame: view.bounds)
// create KYCircularProgress with gauge guide
let circularProgress = KYCircularProgress(frame: view.bounds, showGuide: true)
渐变颜色
// support Hex color to RGBA color
circularProgress.colors = [UIColor(rgba: 0xA6E39D11), UIColor(rgba: 0xAEC1E355), UIColor(rgba: 0xAEC1E3AA), UIColor(rgba: 0xF3C0ABFF)]
// combine Hex color and UIColor
circularProgress.colors = [.purple, UIColor(rgba: 0xFFF77A55), .orange]
进度关闭
circularProgress.progressChanged {
(progress: Double, circularProgress: KYCircularProgress) in
print("progress: \(progress)")
}
UIBezierPath 进度条
// create "Star progress bar"
let path = UIBezierPath()
path.move(to: CGPoint(x: 50.0, y: 2.0))
path.addLine(to: CGPoint(x: 84.0, y: 86.0))
path.addLine(to: CGPoint(x: 6.0, y: 33.0))
path.addLine(to: CGPoint(x: 96.0, y: 33.0))
path.addLine(to: CGPoint(x: 17.0, y: 86.0))
path.close()
starProgress.path = path
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。
要使用 CocoaPods 将 KYCircularProgress 集成到您的 Xcode 项目中,在您的 podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'KYCircularProgress'
然后,运行以下命令
$ pod install
Carthage (iOS 8+)
Carthage 是一个去中心化的依赖管理器,可以自动化将框架添加到您的 Cocoa 应用程序的过程。
您可以使用以下命令通过 Homebrew 安装 Carthage
$ brew update
$ brew install carthage
要使用 Carthage 将 KYCircularProgress 集成到您的 Xcode 项目中,在您的 Cartfile
中指定它
github "kentya6/KYCircularProgress" >= 1.2.0
手动
将 KYCircularProgress.swift
文件添加到您的 Xcode 项目中。
许可证
MIT 许可证 (MIT)
版权所有 (c) 2014-2018 Kengo YOKOYAMA