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

overlay(_:alignment:)

Layers a secondary view in front of this view.

Declaration 宣言

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

Return Value 戻り値

A view that layers overlay in front of the view. あるビュー、それはoverlayをビューの前に重ねたものです。

Parameters パラメータ

overlay

The view to layer in front of this view.

alignment

The alignment for overlay in relation to this view.

Discussion 議論

When you apply an overlay to a view, the original view continues to provide the layout characteristics for the resulting view. あなたがオーバーレイ(被せもの)をビューに適用する時、元のビューは、結果ビューに対するレイアウト特徴を提供し続けます。 In the following example, the heart image is shown overlaid in front of, and aligned to the bottom of the folder image.


Image(systemName: "folder")
    .font(.system(size: 55, weight: .thin))
    .overlay(Text("❤️"), alignment: .bottom)

View showing placement of a heart overlaid onto a folder