.tint()
Published Nov 22, 2023
Contribute to Docs
The .tint()
modifier sets the tint color displayed in a view.
Syntax
Button("This is a button")
.tint(color)
The .tint()
applies the color
to the Button
which conforms it to the View
protocol.
Example
struct ContentView: View {var body: some View {Button("This is a button").tint(.blue)}}
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:
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.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SwiftUI on Codecademy
- Skill path
Build iOS Apps with SwiftUI
Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.Includes 7 CoursesWith CertificateBeginner Friendly13 hours - Free course
Learn Swift
A powerful programming language developed by Apple for iOS, macOS, and more.Beginner Friendly12 hours