Contents

clipToLayer(opacity:options:content:)

Adds a clip shape that you define in a new layer to the context’s array of clip shapes.

Declaration

mutating func clipToLayer(opacity: Double = 1, options: GraphicsContext.ClipOptions = ClipOptions(), content: (inout GraphicsContext) throws -> Void) rethrows

Parameters

  • opacity:

    A value that SwiftUI uses to multiply the alpha channel of the rasterized layer that you define in the content closure. The alpha values that result define the clip shape.

  • options:

    A set of options that tell SwiftUI how to interpret the clip shape. For example, you can invert the clip shape by setting the Inverse option.

  • content:

    A closure that receives as input a new Graphicscontext, which represents a new transparency layer. The alpha channel of content that you draw into this context, multiplied by the opacity parameter, defines the clip shape.

Discussion

Call this method to add a shape to the array of clip shapes that the context uses to define a clipping mask. Shapes that you add affect only subsequent drawing operations.

See Also

Masking