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

# clear(_:)

Paints a transparent rectangle.

## Declaration

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

## Parameters

- `rect`: The rectangle, in user space coordinates.

## Discussion

Discussion If the provided context is a window or bitmap context, Core Graphics clears the rectangle. For other context types, Core Graphics fills the rectangle in a device-dependent manner. However, you should not use this function in contexts other than window or bitmap contexts.

## See Also

### Drawing Shapes

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