Last active
October 15, 2025 11:34
-
-
Save kristofk/44c1ac5ff4b707052ae833225874fc35 to your computer and use it in GitHub Desktop.
Debug UIAccessibilityTraits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension UIAccessibilityTraits: @retroactive CustomStringConvertible { | |
| public var description: String { | |
| var traits = [String]() | |
| if contains(.none) { traits.append("none") } | |
| if contains(.button) { traits.append("button") } | |
| if contains(.link) { traits.append("link") } | |
| if #available(iOS 6.0, *) { | |
| if contains(.header) { traits.append("header") } | |
| } | |
| if contains(.searchField) { traits.append("searchField") } | |
| if contains(.image) { traits.append("image") } | |
| if contains(.selected) { traits.append("selected") } | |
| if contains(.playsSound) { traits.append("playsSound") } | |
| if contains(.keyboardKey) { traits.append("keyboardKey") } | |
| if contains(.staticText) { traits.append("staticText") } | |
| if contains(.summaryElement) { traits.append("summaryElement") } | |
| if contains(.notEnabled) { traits.append("notEnabled") } | |
| if contains(.updatesFrequently) { traits.append("updatesFrequently") } | |
| if #available(iOS 4.0, *) { | |
| if contains(.startsMediaSession) { traits.append("startsMediaSession") } | |
| if contains(.adjustable) { traits.append("adjustable") } | |
| } | |
| if #available(iOS 5.0, *) { | |
| if contains(.allowsDirectInteraction) { traits.append("allowsDirectInteraction") } | |
| if contains(.causesPageTurn) { traits.append("causesPageTurn") } | |
| } | |
| if #available(iOS 10.0, *) { | |
| if contains(.tabBar) { traits.append("tabBar") } | |
| } | |
| if #available(iOS 17.0, *) { | |
| if contains(.toggleButton) { traits.append("toggleButton") } | |
| if contains(.supportsZoom) { traits.append("supportsZoom") } | |
| } | |
| return "[\(traits.joined(separator: ", "))]" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment