实例方法
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:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。