A binding to a value that updates when the user rotates the Digital Crown.
digitalCrownRotation(_:from:through:by:sensitivity:isContinuous:isHapticFeedbackEnabled:)
Availability 有効性
- watchOS 6.0+
Technology
- Swift
UI
Declaration 宣言
func digitalCrownRotation<V>(_ binding: Binding
<V>, from minValue: V, through maxValue: V, by stride: V.Stride? = nil, sensitivity: DigitalCrownRotationalSensitivity
= .high, isContinuous: Bool
= false, isHapticFeedbackEnabled: Bool
= true) -> some View
where V : BinaryFloatingPoint
, V.Stride : BinaryFloatingPoint
Parameters パラメータ
binding
minValue
Lower end of the range reported. 報告される範囲の下側の終わり。
maxValue
Upper end of the range reported. 報告される範囲の上側の終わり。
stride
The value settles on multiples of
stride
.sensitivity
How much the user needs to rotate the Digital Crown to move between two integer numbers.
isContinuous
Controls if the value reported stops at
min
andValue max
, or if it should wrap around. Default isValue false
. 省略時はfalse
です。isHapticFeedbackEnabled
Controls the generation of haptic feedback when turning the Digital Crown. Default is
true
. 「デジタルクラウン」を回している時、触覚フィードバックの発生を制御します。省略時はtrue
です。
Discussion 議論
Use this method to receive values on a binding you provides as the user turns the Digital Crown on Apple Watch. The example below receives changes to the binding value, starting at the min
of 0
up to the max
of 10
in steps of 0
incrementing or decrementing depending on the direction that the user turns the Digital Crown, rolling over if the user exceeds the specified boundary values:
struct DigitalCrown: View {
private var crownValue = 0.0
private var minValue = 0.0
private var maxValue = 10.0
private var stepAmount = 0.1
var body: some View {
Text("Received Value:\(crownValue, specifier: "%.2f")")
.focusable()
.digitalCrownRotation($crownValue,
from: minValue,
through: maxValue,
by: stepAmount,
sensitivity: .low,
isContinuous: true)
}
}