Generic Instance Method


Layers a secondary view in front of this view.


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



The view to layer in front of this view.


The alignment for overlay in relation to this view.

Return Value

A view that layers overlay in front of this view.


When you apply an overlay to a view, the original view continues to provide the layout characteristics for the resulting view. For example, the layout for the caption in this view fits within the width of the image:

        HStack {
            Text("Artichokes") // Text to use as a caption.

        alignment: .bottom

See Also

Setting the Foreground or Background of a View

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software