So I wanted to combine multiple text views in SwiftUI with different colors but it just got very complicated after adding a 5th Text View and adding a view modifier for the foreground and then it was giving me weird errors and saying to break up the view into distinct sub views.
struct dialogueBox: View {
var body: some View {
GroupBox {
Group {
Text("this").foregroundColor(.pink)
+ Text(" code ")
+ Text("works")
+ Text(" well ").foregroundColor(.green)
}.font(.footnote)
Group {
Text("but").foregroundColor(.pink)
+ Text(" this ")
+ Text("code")
+ Text(" does ").foregroundColor(.green)
+ Text(" not ").foregroundColor(.blue)
+ Text(" for some reason ").foregroundColor(.red)
}.font(.footnote)
}
}
}