Updated for Xcode 13.0
SwiftUI automatically uses the names of your images for screen reader labels, which is helpful if you have image names like “Photo of Paul Hudson” or “Hacking with Swift logo.” However, some images aren’t meant to be read because they are merely decorative – they don’t convey information that isn’t already elsewhere on the screen, or are instead just there to make the user interface look more attractive.
If you create these images using something like
Image("star") the screen reader will read them out as part of its standard UI pass. A better idea is to create them using using the
Image(decorative:) initializer, which tells SwiftUI the image shouldn’t be exposed to the screen reader:
Once you’ve built your user interface it’s worth doing a final check over using VoiceOver to make sure you have marked your images correctly – the last thing you want is the screen reader speaking out weird internal filenames that you thought were only used in your code!
SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.
Link copied to your pasteboard.