實例方法
digital
digitalCrownRotation(_:from:through:by:sensitivity:isContinuous:isHapticFeedbackEnabled:)
通過更新指定的綁定來跟蹤 Digital Crown 旋轉。
聲明
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
參數
binding
與用戶旋轉數字表冠時更新的值的綁定。
minValue
報告範圍的下限。
maxValue
報告範圍的上限。
stride
該值確定為
stride
的倍數。sensitivity
用戶需要旋轉多少數字表冠才能在兩個整數之間移動。
isContinuous
控製報告的值是否在
minValue
和maxValue
處停止,或者是否應該環繞。默認為false
。isHapticFeedbackEnabled
控製轉動 Digital Crown 時產生的觸覺反饋。默認為
true
。
詳述
當用戶在 Apple Watch 上轉動 Digital Crown 時,使用此方法接收您提供的綁定上的值。下麵的示例接收綁定值的更改,從 0.0
的 minValue
到 10.0
的 maxValue
以 0.1
遞增或遞減的步長取決於用戶轉動數字表冠的方向,如果用戶超過指定的邊界值,則翻轉:
struct DigitalCrown: View {
@State private var crownValue = 0.0
@State private var minValue = 0.0
@State private var maxValue = 10.0
@State 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)
}
}
可用版本
watchOS 6.0+
相關用法
- Swift Never digitalCrownRotation(_:)用法及代碼示例
- Swift Never disabled(_:)用法及代碼示例
- Swift Never defaultWheelPickerItemHeight(_:)用法及代碼示例
- Swift Never drawingGroup(opaque:colorMode:)用法及代碼示例
- Swift Never dynamicTypeSize(_:)用法及代碼示例
- Swift Never pageCommand(value:in:step:)用法及代碼示例
- Swift Never opacity(_:)用法及代碼示例
- Swift Never colorMultiply(_:)用法及代碼示例
- Swift Never accessibilityAction(action:label:)用法及代碼示例
- Swift Never alert(isPresented:error:actions:message:)用法及代碼示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代碼示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代碼示例
- Swift Never position(x:y:)用法及代碼示例
- Swift Never position(_:)用法及代碼示例
- Swift Never luminanceToAlpha()用法及代碼示例
- Swift Never accessibilityAction(_:_:)用法及代碼示例
- Swift Never previewDisplayName(_:)用法及代碼示例
- Swift Never badge(_:)用法及代碼示例
- Swift Never progressViewStyle(_:)用法及代碼示例
- Swift Never buttonStyle(_:)用法及代碼示例
- Swift Never popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代碼示例
- Swift Never projectionEffect(_:)用法及代碼示例
- Swift Never onTapGesture(count:perform:)用法及代碼示例
- Swift Never overlay(_:in:fillStyle:)用法及代碼示例
- Swift Never background(_:ignoresSafeAreaEdges:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never digitalCrownRotation(_:from:through:by:sensitivity:isContinuous:isHapticFeedbackEnabled:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。