stroke

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

ShapeView ModifieriOS 17.0+macOS 14.0+tvOS 17.0+watchOS 10.0+

Overloads

2 ways to call compose().stroke(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().stroke(
  content: SwiftUI.ShapeStyle,
  options?: {
    lineWidth?: number;
    antialiased?: boolean;
  }
)
Swift
@export(implementation) nonisolated func stroke<S>(
    _ content: S,
    lineWidth: CGFloat = 1,
    antialiased: Bool = true
) -> StrokeShapeView<Self.Content, S, Self>
where S : ShapeStyle

Parameters

  • The color or gradient with which to stroke this shape.

  • options.lineWidthnumber

    The width of the stroke that outlines this shape.

  • options.antialiasedboolean

    A Boolean value that specifies whether to allow antialiasing. Pass true to allow antialising, otherwise false.

Return value

A stroked shape.

Discussion

The following example draws a circle with a purple stroke:

Circle().stroke(Color.purple, lineWidth: 5)

See also

More in ShapeView modifiers.