要求
- Xcode 11+
- Swift 5
- iOS 10.0+
安装
CocoaPods
pod 'MeterGauge', :git => '[email protected]:boof-tech/MeterGauge.git', :tag => '0.0.5'
用法
导入 MeterGauge
import MeterGauge
创建仪表表实例
var gaugeView: MeterGauge = MeterGauge(frame: view.bounds)
设置分段
let color = UIColor(red: 0.3, green: 0.5, blue: 0.2, alpha: 1.0)
let segment = Segment(percent: 100, color: color, status: "")
guageView.segments.append(segment)
更新值
gaugeView.set(value : Int)
定制仪表表
- 值
gaugeView.valueFont = UIFont.systemFont(ofSize: 28, weight: .heavy)
gaugeView.valueTextColor = UIColor.black
- 描述
gaugeView.descriptionFont = UIFont.systemFont(ofSize: 28, weight: .heavy)
gaugeView.descriptionTextColor = UIColor.black
- 中心圆圈
gaugeView.centerCircleBackgroundColor = UIColor.clear
gaugeView.centerCircleBorderWidth = 3.0
- 刻度标记
gaugeView.tickWidth = 7.0
gaugeView.beforeIndicatorTickOpacity = 1.0
gaugeView.afterIndicatorTickOpacity = 0.3
- 指示器刻度宽度
gaugeView.indicatorTickHeight = 10.0
gaugeView.indicatorTickScale = 1.0
gaugeView.indicatorTickOpacity = 1.0
授权
仪表表遵循MIT许可。有关更多信息,请参阅LICENSE.txt文件。