foregroundColor(_:)
Sets the color of the text displayed by this view.
Declaration
nonisolated func foregroundColor(_ color: Color?) -> TextParameters
- color:
The color to use when displaying this text.
Return Value
A text view that uses the color value you supply.
Discussion
Use this method to change the color of the text rendered by a text view.
For example, you can display the names of the colors red, green, and blue in their respective colors:
HStack {
Text("Red").foregroundColor(.red)
Text("Green").foregroundColor(.green)
Text("Blue").foregroundColor(.blue)
}[Image]