UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: How to use SF Symbols with Image(Decorative: )

Forums > SwiftUI

In my app, I use SF Symbols to make it look better, but when using voice over it would read the name of the SF Symbol, which is something I'm trying to avoide.

But I just haven't found a solution to my problem.

Thanks in advance!

2      

Thought of a workaround!

In the SF Symbols app:

  1. Select the SF Symbol I needed
  2. Go to FIle -> Export Custom Symbol Template
  3. Keep the name the same
  4. Added the .svg to the assets folder

Now I can use:

Image(decorative: "SFSymbolName")

I think that this solution only works with SwiftUI 2.0 and iOS 14+.

2      

I think there is an easier solution: use the .accessibility(hidden:) modifier

Image(systemName: "SFSymbolName")
  .accessibility(hidden: true)

This should remove the image completely from VoiceOver.

4      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.