With VoiceOver, you can swipe up/down to increase/decrease the value of adjustable components. You need to implement accessibilityIncrement() and accessibilityDecrement() accordingly, and configure an accessibility value that makes sense.

A component lets you rate the Regency Cafe restaurant from one, to five thumbs up. It is currently at 5. It shows that swiping up will increase value and swiping down will decrease it. The code shows how you can override accessibility increment and decrement to adjust the accessibility value to something like

Example code in the image:

override func accessibilityIncrement() {
    guard value < 5 else { return }
    value += 1
    accessibilityValue = "\(value) of 5"
    sendActions(for: .valueChanged)
}

override func accessibilityDecrement() {
  guard value > 1 else { return }
  value -= 1
  accessibilityValue = "\(value) of 5"
  sendActions(for: .valueChanged)
}

Links to the official documentation:

* accessibilityincrement()

* accessibilitydecrement()

You may also find interesting...

Accessibility values are about state. Using them appropriately will make the experience better for Voice Control users. Think of a repeat button (values could be: off, one or all songs) or a notifications tab (value could be: x new items). For more on accessibility values, check out this fantastic blog post from @MobileA11y with info on the APIs (UIKit, SwiftUI), accessibility attributed values, WCAG, or some more examples (text in a text field, value on a stepper or slider). https://mobilea11y.com/blog/accessibility-values/

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

accessibilitySpeechPitch lets you emphasise something changing VoiceOver's pitch. The value goes from 0.0 to 2.0. The default is 1.0. Twitter could change pitch to read hashtags, for example, avoiding repetition but still signalling they're there.

Created in Swift with Ignite.

Supporting Swift for Swifts