Trikalabs
  • Home
  • Best online TDD videos
  • Book Suggestions
  • About Me
  • Contact
Trikalabs
No Result
View All Result

SwiftUI – Accessibility for Images

by fragi
May 13, 2021
in Accessibility
Share on FacebookShare on Twitter

Supporting dynamic type for text is essential to make the app accessible. Making images accessible sometimes is out of the box(system images) and sometimes requires a bit of work.
Let’s explore some very common cases:
The first decision we have to take is to decide if the image is a UI decoration or it carries essential information. By default in SwiftUI the images are accessible so when the image is just decoration we should make it non accessible.
If the image is a system image:

Swift
1
Image(systemName: "figure.walk")

then we can make it non accessible by using the following code:

Swift
1
2
Image(systemName: "figure.walk")
  .accessibility(hidden: true)

If the image is custom image, the we can initialise the image as follows:

Swift
1
Image(decorative:"walk")

Another thing to consider is when the text grows, the image has to grow also. This happens automatically for system images, but not for custom images and unlikely the UIKit  here we don’t have the API to support it. So for the custom images we have to create our custom symbol by following the Apple’s instructions https://developer.apple.com/documentation/uikit/uiimage/creating_custom_symbol_images_for_your_app.

Lastly when the image file is not readable or suitable for voice over, then we can add our own  text for voice over:

Swift
1
Image("randomName", label: Text("walk"))

Tags: AccessibilityImageSwiftUI
fragi

fragi

Related Posts

Accessibility by Example
Accessibility

Accessibility – AutoResizable views

February 18, 2022

Allow a user to select the text size is a must if your app wants to be accessible. IOS already...

Accessibility by Example
Accessibility

Accessibility by Example

January 28, 2022

This post contains notes and screenshots from WWDC accessibility videos. Accessibility in SwiftUI (WWDC 2019) - Add label to describe...

Large Content Viewer
Accessibility

Large Content Viewer

May 13, 2021

Although scaling dynamic type is preferred whenever possible, there are cases as the navigation bars, the tab bars, the toolbars...

Next Post
What is TDD?

FizzBuzzThrow - step by step TDD

What is TDD?

What is TDD?

What is TDD?

FizzBuzz Kata - step by step TDD

  • Advertise
  • Privacy & Policy
  • Contact

© 2019 Trikalabs Ltd. All rights reserved.

No Result
View All Result
  • Home
  • About Me
  • A curated list with the best free online TDD videos
  • Book Suggestions
  • Pinner Code Club

© 2019 Trikalabs Ltd. All rights reserved.