Instance Method

grayscale(_:)

Adds a grayscale effect to the view.

Declaration

func grayscale(_ amount: Double) -> some View

Parameters

amount

The intensity of grayscale to apply. Values closer to 0.0 are more colorful, and values closer to 1.0 are less colorful.

Return Value

A view that adds a grayscale effect to this view.

Discussion

A grayscale effect reduces the intensity of colors in this view. The following shows two versions of the same image side by side; at left is the original, and at right is a duplicate with the grayscale(_:) modifier’s amount parameter set to 0.75:

See Also

Applying Graphical Effects to a View

func blur(radius: CGFloat, opaque: Bool) -> View

Applies a Gaussian blur to the view.

func opacity(Double) -> View

Sets the transparency of the view.

func brightness(Double) -> View

Brightens the view by the specified amount.

func contrast(Double) -> View

Sets the contrast and separation between similar colors in the view.

func colorInvert() -> View

Inverts the colors in the view.

func colorMultiply(Color) -> View

Adds a color multiplication effect to the view.

func saturation(Double) -> View

Adjusts the color saturation of the view.

func hueRotation(Angle) -> View

Applies a hue rotation effect to the view.

func luminanceToAlpha() -> View

Adds a luminance to alpha effect to the view.