Instance Method インスタンスメソッド

tint(_:)

Sets the tint color within this view.

Declaration 宣言

func tint(_ tint: Color?) -> some View

Parameters パラメータ

tint

The tint Color to 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 green and 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)
        }
        .padding()
    }
}

See Also 参照

Tint