Skip to content

Commit b0d729d

Browse files
committed
Check UISwitch state using combination of trait and value
1 parent 0f195fb commit b0d729d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Sources/AccessibilitySnapshot/Core/Swift/Classes/UIAccessibility+SnapshotAdditions.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,11 @@ extension NSObject {
107107
}
108108

109109
if accessibilityTraits.contains(.switchButton) {
110-
if let `self` = self as? UISwitch {
111-
if self.isOn {
112-
traitSpecifiers.append(strings.switchButtonOnTraitName)
113-
} else {
114-
traitSpecifiers.append(strings.switchButtonOffTraitName)
115-
}
116-
110+
// TODO: Do these need to be localized by script? What about other integers? What about non-integer accessibility values?
111+
if accessibilityValue == "1" {
112+
traitSpecifiers.append(strings.switchButtonOnTraitName)
113+
} else if accessibilityValue == "0" {
114+
traitSpecifiers.append(strings.switchButtonOffTraitName)
117115
} else if accessibilityTraits.contains(.button) {
118116
// An element can have the private switch button trait without being a UISwitch (for example, by passing through
119117
// the traits of a contained switch). In this case, VoiceOver will still read the "Switch Button." trait, but

0 commit comments

Comments
 (0)