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

# setLineWidth(_:)

Sets the line width for a graphics context.

## Declaration

```swift
func setLineWidth(_ width: CGFloat)
```

## Parameters

- `width`: The new line width to use, in user space units. The value must be greater than 0.

## Discussion

Discussion The default line width is 1 unit. When stroked, the line straddles the path, with half of the total width on either side.

## See Also

### Setting Path Drawing Options

- [setAllowsAntialiasing(_:)](coregraphics/cgcontext/setallowsantialiasing(_:).md)
- [setFlatness(_:)](coregraphics/cgcontext/setflatness(_:).md)
- [setLineCap(_:)](coregraphics/cgcontext/setlinecap(_:).md)
- [setLineDash(phase:lengths:)](coregraphics/cgcontext/setlinedash(phase:lengths:).md)
- [setLineJoin(_:)](coregraphics/cgcontext/setlinejoin(_:).md)
- [setMiterLimit(_:)](coregraphics/cgcontext/setmiterlimit(_:).md)
- [setPatternPhase(_:)](coregraphics/cgcontext/setpatternphase(_:).md)
- [setFillPattern(_:colorComponents:)](coregraphics/cgcontext/setfillpattern(_:colorcomponents:).md)
- [setShouldAntialias(_:)](coregraphics/cgcontext/setshouldantialias(_:).md)
