Published Nov 22, 2023
Contribute to Docs

The .tint() modifier sets the tint color displayed in a view.


Button("This is a button")

The .tint() applies the color to the Button which conforms it to the View protocol.


struct ContentView: View {
var body: some View {
Button("This is a button")

In the above example, the .tint() modifier with the .blue parameter is called on the Button view. This applies the blue tint color to the button.

This will display the following:

SwiftUI Button with blue tint color

Note: When a tint is applied to a view hierarchy, it only affects the text inside controls, like buttons and links, not plain Text views.

All contributors

Looking to contribute?

Learn SwiftUI on Codecademy