Build accessible apps with SwiftUI and UIKit

Accessibility is key for Apple.  I agree with this philosophy, having even written an article years ago for the magazine called “Enabled” on how OS/2 was made accessible.  I loved that the magazine was called “Enabled” instead of “Disabled” as it sent a message to the reader that they were not less than.

Accessibility Enhancements

  • Adding hints via .accessibilityAddTraits(.isToggle) lets the system know that this button has a toggle trait to provide proper hint and switch button information
    • Also available in UIKit
  • You can add new announcements to do things like let user know screen is loading
    • Accessibility Notifications – can be created for “Announcement”, “LayoutChanged’, “ScreenChanged”, and “PageScrolled” messages to assistive devices, etc,
    • The API is pretty simple – `AccessibilityNotification.Announcement(“TEXT”).post()`
    • You can set announcement priority so they don’t overlap and cut each other off, if there are a series of announcements going in sequence.
  • Accessibility Zoom Action .accessibilityZoomAction modifier allows for zooming via voice over.
  • .allowsDirectInteraction trait allows you to define a region of the screen for direct interaction with your app, you can bypass voice over – you can .silentOnTouch and .requiresActivation as options

Improve Accessibility Visual

  • .contentShape(.accessibility, type) – to control accessibility actions on the screen.  You can create custom cursor visuals, you can apply this to a view and

Keep state up-to-date

  • Block based attribute setters is coming
  • You can now keep underlying attributes up to date. This provides a closure for attributes (whenever it is needed). It is reevaluated whenever it is accessed by assistive technology.
  • It must return the correct type, this makes it easier to maintain the elements.