Contents

stroke(_:style:)

Traces the outline of this shape with a color or gradient.

Declaration

nonisolated func stroke<S>(_ content: S, style: StrokeStyle) -> some View where S : ShapeStyle

Parameters

  • content:

    The color or gradient with which to stroke this shape.

  • style:

    The stroke characteristics — such as the line’s width and whether the stroke is dashed — that determine how to render this shape.

Return Value

A stroked shape.

Discussion

The following example adds a dashed purple stroke to a Capsule:

Capsule()
.stroke(
    Color.purple,
    style: StrokeStyle(
        lineWidth: 5,
        lineCap: .round,
        lineJoin: .miter,
        miterLimit: 0,
        dash: [5, 10],
        dashPhase: 0
    )
)

See Also

Setting the stroke characteristics