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...

With regular buttons from UIKit or SwiftUI, you are all set. With complex views, headings, or table/collection view cells that, when selected, bring the user somewhere else in the app or perform an action, you'll have to add the button trait.

With the Accessibility Inspector you can check the value for the most common accessibility attributes for individual elements, do some basic navigation, and even perform actions if the component is adjustable or if it has custom actions.

Meet @jordibruin developer of Navi (and other great apps) and organizer of @swiftuiseries (with an accessibility category). Navi is sadly not available anymore but it was worth an Apple Design Awards nomination. It added subtitles to FaceTime!

Created in Swift with Ignite.

Supporting Swift for Swifts