stroke

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

Shape ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+

Overloads

6 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;
  }
)
Swift
nonisolated func stroke<S>(
    _ content: S,
    lineWidth: CGFloat = 1
) -> some View
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.

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 Shape modifiers.