实例方法
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 Optional digitalCrownRotation(_:)用法及代码示例
- Swift Optional disabled(_:)用法及代码示例
- Swift Optional dynamicTypeSize(_:)用法及代码示例
- Swift Optional defaultWheelPickerItemHeight(_:)用法及代码示例
- Swift Optional drawingGroup(opaque:colorMode:)用法及代码示例
- Swift Optional symbolVariant(_:)用法及代码示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代码示例
- Swift Optional mask(alignment:_:)用法及代码示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代码示例
- Swift Optional badge(_:)用法及代码示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代码示例
- Swift Optional keyboardType(_:)用法及代码示例
- Swift Optional clipShape(_:style:)用法及代码示例
- Swift Optional preferredColorScheme(_:)用法及代码示例
- Swift Optional background(_:ignoresSafeAreaEdges:)用法及代码示例
- Swift Optional saturation(_:)用法及代码示例
- Swift Optional focusSection()用法及代码示例
- Swift Optional overlay(alignment:content:)用法及代码示例
- Swift Optional colorMultiply(_:)用法及代码示例
- Swift Optional confirmationDialog(_:isPresented:titleVisibility:presenting:actions:message:)用法及代码示例
- Swift Optional offset(_:)用法及代码示例
- Swift Optional focused(_:equals:)用法及代码示例
- Swift Optional hidden()用法及代码示例
- Swift Optional previewDevice(_:)用法及代码示例
- Swift Optional keyboardShortcut(_:modifiers:localization:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Optional digitalCrownRotation(_:from:through:by:sensitivity:isContinuous:isHapticFeedbackEnabled:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。