NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

Introduction to accessibility with SwiftUI

Paul Hudson    @twostraws   

Updated for Xcode 12.0

By default SwiftUI apps come with a remarkably high level of accessibility, which is no accident – it was planned into the framework from the earliest days, and unless you actively choose to work around the defaults you’ll find your apps do a good job of being accessible without much special work from you.

The key to this behavior is the stack-based approach of SwiftUI’s layouts: everything has a natural order because we place things inside HStack and VStack, so the system can understand roughly how our layout should flow. In comparison, UIKit and Auto Layout let us place things anywhere, so the system effectively had to make a best guess as to how things should be ordered.

SwiftUI also strongly encourages us to add labels to all our interactive controls, explicitly saying what everything is for. Yes, we can hide those labels, but even when they are hidden they are still used by the system as audio prompts for the screen reader and more.

So, SwiftUI gives us a lot of accessibility for free. However, it still gives us extra tools to provide a more enhanced experience: how should things be read by the screen reader? Does everything need to be read? What if the user prefers not to have fancy animations?

In this collection of chapters we’re going to look at these more advanced pieces of functionality, hopefully helping you build user interfaces that provide users with a comfortable experience regardless of their system preferences.

Hacking with Swift is sponsored by NSSpain

SPONSORED Announcing NSSpain 2020: Remote Edition! An online, continuous conference for iOS developers. We’ll start on Thursday and finish on Friday, with talks, activities, and lots of fun for 36 hours, non-stop. Sound good? Join us!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Similar solutions…

Buy Pro Swift Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift (Vapor Edition) Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Server-Side Swift (Kitura Edition) Buy Beyond Code

Was this page useful? Let us know!

Average rating: 4.0/5

Link copied to your pasteboard.