---
title: "clip(to:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigraphicsrenderercontext/clip(to:)"
---

# clip(to:)

Sets the clipping mask for the drawing context to the specified rectangle.

## Declaration

```swift
func clip(to rect: CGRect)
```

## Parameters

- `rect`: The rectangle to which the drawing context is clipped, specified in the Core Graphics coordinate space with values in points.

## Discussion

Discussion To restrict the active drawing area to the specified rectangle, call this method before executing drawing commands. To use a more complex shape as a clipping mask, use the clip(to:mask:) method on the underlying Core Graphics context, accessed through the cgContext property.
