init(value:in:label:)
Creates a gauge showing a value within a range and describes the gauge’s purpose and current value.
Declaration
init<V>(value: V, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label) where CurrentValueLabel == EmptyView, BoundsLabel == EmptyView, MarkedValueLabels == EmptyView, V : BinaryFloatingPointParameters
- value:
The value to show in the gauge.
- bounds:
The range of the valid values. Defaults to
0...1. - label:
A view that describes the purpose of the gauge.
Discussion
Use this modifier to create a gauge that shows the value at its relative position along the gauge and a label describing the gauge’s purpose. In the example below, the gauge has a range of 0...1, the indicator is set to 0.4, or 40 percent of the distance along the gauge:
struct SimpleGauge: View {
@State private var batteryLevel = 0.4
var body: some View {
Gauge(value: batteryLevel) {
Text("Battery Level")
}
}
}[Image]