Accessibility up to 11! LogoAccessibility up to 11!
  • Blog
  • #365DaysIOSAccessibility
  • Apps
  • About
  • Resources
  • RSS
#365DaysIOSAccessibility

Day 2

20 May 2022

Accessibility ModifiersSwiftUIUIAccessibilityUIKit

By

Daniel Devesa Derksen-Staats

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

You may also find interesting...

Day 68

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:)

Switch ControlUIAccessibilityUIAccessibilityCustomActioniOS

Day 105

The .accessibilityElement(children: ) modifier with the .ignore argument does a similar thing to set the container view to be an accessibility element in UIKit. It is the default argument, so you can just say .accessibilityElement(). Because of this, you'll need to use other modifiers to make it accessible and manually configure an accessibility label and value, traits... when necessary. https://developer.apple.com/documentation/swiftui/view/accessibilityelement(children:) https://developer.apple.com/documentation/swiftui/accessibilitychildbehavior/ignore

UIKitaccessibilityElement

Day 108

In UIKit, to create an adjustable component we need to add the adjustable trait and override both accessibilityIncrement() and accessibilityDecrement(). In SwiftUI, everything you need is bundled in the accessibilityAdjustableAction(_:) modifier.

SwiftUIUIKitaccessibilityAdjustableActionadjustable

Content © Daniel Devesa Derksen-Staats on Accessibility up to 11! is licensed under CC BY 4.0. License details


← Day 3
Day 1 →

Created in Swift with Ignite.

Supporting Swift for Swifts