Tag: UIAccessibility
6 posts
Tag: UIAccessibility
6 posts
In iOS' Settings you can specify your preference to use bold text. This can be checked in code in a couple ways: 1. isBoldTextEnabled in UIAccessibility: https://developer.apple.com/documentation/uikit/uiaccessibility/isboldtextenabled 2. legibilityWeight from UITraitCollection: https://developer.apple.com/documentation/uikit/uitraitcollection/legibilityweight

There are a ton of customisation options in the accessibility settings in iOS. When doing things the Apple way, this options should, in most cases, just work for you. If not, you can find flags to check for all these options in UIAccessibility.

Creating UIAccessibilityElements, combined with a semanticGroup accessibilityContainerType, can also help you make components as complex as charts accessible. Example from "Bring Accessibility to Charts" WWDC21: https://developer.apple.com/videos/play/wwdc2021/10122/

Since iOS 14, UIAccessibilityCustomAction has an initialiser that accepts an image, as well as a name and action handler. Configuring one will make your custom actions easier to spot in the Switch Control menu. https://developer.apple.com/documentation/uikit/uiaccessibilitycustomaction/init(name:image:actionhandler:)
SwiftUI has equivalent accessibility modifiers for some of UIAccessibility's properties in UIKit. Same basic concepts apply. Label: https://developer.apple.com/documentation/swiftui/view/accessibilitylabel(_:)-9ek2h Value: https://developer.apple.com/documentation/swiftui/view/accessibilityvalue(_:)-8esl7 Traits: https://developer.apple.com/documentation/swiftui/view/accessibilityaddtraits(_:) Hint: https://developer.apple.com/documentation/swiftui/view/accessibilityhint(_:)-3i2vu

UIAccessibility is the cornerstone of any accessible UIKit app. Among others, understanding what an accessibility label, value, trait or hint are, is key. This is an example of how they could be configured for a custom rating component. #GAAD2022