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

mask(alignment:_:)

Masks this view using the alpha channel of the given view. このビューをこの与えられたビューのアルファチャンネルを使って隠します。

Declaration 宣言

func mask<Mask>(alignment: Alignment = .center, _ mask: () -> Mask) -> some View where Mask : View

Parameters パラメータ

alignment

The alignment for mask in relation to this view.

mask

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

Discussion 議論

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")
    .foregroundColor(Color.blue)
    .font(.system(size: 128, weight: .regular))
    .mask {
        Rectangle().opacity(0.1)
    }

A screenshot of a view masked by a rectangle with 10%

See Also 参照

Masks and Clipping