---
title: "stroke(_:)"
framework: coregraphics
role: symbol
role_heading: Instance Method
path: "coregraphics/cgcontext/stroke(_:)"
---

# stroke(_:)

Paints a rectangular path.

## Declaration

```swift
func stroke(_ rect: CGRect)
```

## Parameters

- `rect`: A rectangle, specified in user space coordinates.

## Discussion

Discussion The line width and stroke color of the context’s graphics state are used to paint the path. The current path is cleared as a side effect of calling this function.

## See Also

### Drawing Shapes

- [clear(_:)](coregraphics/cgcontext/clear(_:).md)
- [fill(_:)](coregraphics/cgcontext/fill(_:)-7a0rk.md)
- [fill(_:)](coregraphics/cgcontext/fill(_:)-6jc4y.md)
- [fillEllipse(in:)](coregraphics/cgcontext/fillellipse(in:).md)
- [stroke(_:width:)](coregraphics/cgcontext/stroke(_:width:).md)
- [strokeEllipse(in:)](coregraphics/cgcontext/strokeellipse(in:).md)
- [strokeLineSegments(between:)](coregraphics/cgcontext/strokelinesegments(between:).md)
