Generic Instance Method


Masks this view using the alpha channel of the given view.


func mask<Mask>(_ mask: Mask) -> some View where Mask : View



The view whose alpha the rendering system applies to the specified view.


Use mask(_:) when you want to apply the alpha (opacity) value of another view to the current view.

This example shows an image masked by rectangle with a 10% opacity:

Image(systemName: "envelope.badge.fill")
    .font(.system(size: 128, weight: .regular))
A screenshot of a view masked by a rectangle with 10% opacity.

See Also

Masking and Clipping Views

func clipped(antialiased: Bool) -> View

Clips this view to its bounding rectangular frame.

func clipShape<S>(S, style: FillStyle) -> View

Sets a clipping shape for this view.

func cornerRadius(CGFloat, antialiased: Bool) -> View

Clips this view to its bounding frame, with the specified corner radius.