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.

If you create a custom page indicator in SwiftUI, you can make it accessible in SwiftUI by using the .accessibilityAdjustableAction(_: ) modifier. In UIKit, you need three steps instead: add the .adjustable accessibility trait, override accessibilityIncrement(), and override accessibilityDecrement(). The code in SwiftUI is all in one place, the adjustable action modifier provides a closure with the direction of the action. You can use a switch to implement code for each one of the cases, in this case .increment, and .decrement.

You may also find interesting...

Grouping elements in SwiftUI is extremely easy! You can use the .accessibility(children: .combine) modifier. And that's it! It merges properties. For example, generating an accessibility label by joining the children's ones, separated by commas.

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

If you are developing a custom component, that can change value, chances are that it will need the adjustable accessibility trait (VoiceOver will say: "Adjustable"). Think of a component that lets you rate from one to five thumbs up (or stars).

Created in Swift with Ignite.

Supporting Swift for Swifts