In my SwiftUI App I have a TextView based on UIViewRepresentable. TextView displays text in different languages, depending on user action. All the text is always in the same language, i.e. it does not mix text of different languages at a time.
Now, I need to support VoiceOver and the problem is that TextViews text is always spoken in users preferred language, which is often inappropriate. I want to set the TextView's VoiceOver language depending on its text language without affecting my other views.
How to set VoiceOver language in SwiftUI on a view basis ?
Thanks
I'm not sure what you mean by TextView in a SwiftUI context but... if you use a Text view, you can set the Text view's locale as follows:
Text(verbatim: "Hello")
.font(.headline)
.environment(\.locale, .init(identifier: "en"))
Source: Use Your Loaf > SwiftUI Accessibility Language
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With