Accessibility value - SwiftUI
In SwiftUI, you can set an accessibility value with the accessibilityValue
view modifier by providing a Text
value description.
When using the semantically correct element, you usually do not need to modify the accessibilityValue
. For example, a Toggle
sets the accessibilityValue
to On
or Off
and a Slider
sets the accessibilityValue
to the current value. If the default value is incorrect or unclear, you can override the value manually.
@State private var progress: Double = 0
var body: some View {
CustomSlider(value: $progress)
.accessibilityValue("\(progress)")
}