GaugeProgressViewStyle 为 iOS 添加了 Apple Watch 的仪表盘视图。
要安装 GaugeProgressViewStyle,请将 GaugeProgressViewStyle 作为依赖项添加到您的 Package.swift 文件中。
.package(url: "https://github.com/kkla320/GaugeView.git", from: "1.0.0")
只需使用 ProgressView
的 progressViewStyle
方法,并通过名为 gauge
的静态成员之一传递 GaugeProgressViewStyle。 请查看 wiki 以获取详细文档。
代码 | 结果 |
---|---|
ProgressView(value: 0)
.progressViewStyle(.gauge())
|
|
ProgressView(value: 0.5)
.progressViewStyle(.gauge(thickness: 20))
|
|
ProgressView(value: 0.5) {
Text("Gauge")
}
.progressViewStyle(.gauge())
|
|
ProgressView(value: 0.5)
.progressViewStyle(
.gauge {
Text("12")
} upperLabel: {
Text("24")
}
)
|
|
ProgressView(value: 0.5)
.progressViewStyle(
.gauge {
Image(systemName: "sun.max.fill")
} upperLabel: {
Image(systemName: "cloud.rain.fill")
}
)
|
只需创建一个 pull request。