Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to achieve this is to define a custom style for Text and apply it to all instances of Text in the app. Here's an example:

  1. Declare a custom Text style in the app:

    extension Text {
       func myTextStyle() -> Text {
           self
               .foregroundColor(.black) // set the text color here
       }
    }
    
  2. Apply the custom style to all instances of Text in the app:

    struct ContentView: View {
       var body: some View {
           VStack {
               Text("Hello, world!")
                   .myTextStyle() // apply the custom style here
               Text("Another Text")
                   .myTextStyle() // apply the custom style here
               // more Text instances...
           }
       }
    }
    

By using this approach, any modifications to the custom style will be reflected throughout the app.