Overloads
2 ways to call compose().tint(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().tint(tint: SwiftUI.Color | null)nonisolated func tint(_ tint: Color?) -> some ViewParameters
tint*SwiftUI.Color | nullThe tint
Colorto apply.
Discussion
Use this method to override the default accent color for this view. Unlike an app's accent color, which can be overridden by user preference, the tint color is always respected and should be used as a way to provide additional meaning to the control.
This example shows Answer and Decline buttons with ShapeStyle.green
and ShapeStyle.red tint colors, respectively.
struct ControlTint: View {
var body: some View {
HStack {
Button {
// Answer the call
} label: {
Label("Answer", systemImage: "phone")
}
.tint(.green)
Button {
// Decline the call
} label: {
Label("Decline", systemImage: "phone.down")
}
.tint(.red)
}
.buttonStyle(.borderedProminent)
.padding()
}
}Some controls adapt to the tint color differently based on their style,
the current platform, and the surrounding context. For example, in
macOS, a button with the PrimitiveButtonStyle.bordered style doesn't
tint its background, but one with the
PrimitiveButtonStyle.borderedProminent style does. In macOS, neither
of these button styles tint their label, but they do in other platforms.
See also
More in Appearance.
- backgroundSets the view's background to a style.
- badgeGenerates a badge for the view from a localized string resource.
- badgeProminenceSpecifies the prominence of badges created by this view.
- borderAdds a border to this view with the specified style and width.
- buttonSizingThe preferred sizing behavior of buttons in the view hierarchy.
- containerBackgroundSets the container background of the enclosing container using a view.
- headerProminenceSets the header prominence for this view.
- hiddenHides this view unconditionally.
- imageScaleScales images within the view according to one of the relative sizes available including small, medium, and large images sizes.
- labelIconToTitleSpacingSet the spacing between the icon and title in labels.
- labelReservedIconWidthSet the width reserved for icons in labels.
- labelsHiddenHides the labels of any controls contained within this view.