Initializer
init(value:in:label:currentValueLabel:minimumValueLabel:maximumValueLabel:)
Creates a gauge showing a value within a range and describes the gauge’s current, minimum, and maximum values.
Declaration
宣言
init<V>(value: V, in bounds: ClosedRange
<V> = 0...1, label: () -> Label, currentValueLabel: () -> CurrentValueLabel, minimumValueLabel: () -> BoundsLabel, maximumValueLabel: () -> BoundsLabel) where MarkedValueLabels == EmptyView
, V : BinaryFloatingPoint
Parameters
パラメータ
value
The value to show on the gauge.
bounds
The range of the valid values. Defaults to 0...1
.
label
A view that describes the purpose of the gauge.
currentValueLabel
A view that describes the current value of the gauge.
minimumValueLabel
A view that describes the lower bounds of the gauge.
maximumValueLabel
A view that describes the upper bounds of the gauge.
Discussion
議論
Use this method to create a gauge that shows a value within a prescribed bounds. The gauge has labels that describe its purpose, and for the gauge’s current, minimum, and maximum values.
struct LabeledGauge: View {
@State private var current = 67.0
@State private var minValue = 0.0
@State private var maxValue = 170.0
var body: some View {
Gauge(value: current, in: minValue...maxValue) {
Text("BPM")
} currentValueLabel: {
Text("\(Int(current))")
} minimumValueLabel: {
Text("\(Int(minValue))")
} maximumValueLabel: {
Text("\(Int(maxValue))")
}
}
}
See Also
参照
Creating a Gauge
ゲージを作成する