I'm trying to build a Thai language app. To show the sound of a Thai word, I want to use these three special characters "\ / -". For readability, I would like to change the color for these characters to red. Is there a way to do it in SwiftUI?
I'm using this as Model:
struct Alphabet {
var letter: String
var byname: String
var translation: String
var consonantClass: ConsonantClass
}
This is the Viewmodel:
let middleConsonants: [Alphabet] = [
Alphabet(letter: "ก", byname: "gô:- gai\\", translation: "Chicken", consonantClass: .middle)
]
And here, in the View, I would like to show it with the different colors:
struct ConsonantsListView: View {
var vm: ConsonantsViewModel = ConsonantsViewModel()
var consonants: [Alphabet]
var body: some View {
ForEach(0..<consonants.count, id: \.self) { index in
HStack {
Spacer()
NavigationLink(destination:
VStack(spacing: 20) {
Text(consonants[index].byname)
.font(.largeTitle)
Text(consonants[index].translation)
}) {
Text(consonants[index].letter)
.font(.largeTitle)
}
Spacer()
}
}
}
}