---
title: "firstRect(for:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextinput/firstrect(for:)"
---

# firstRect(for:)

Returns the first rectangle that encloses a range of text in a document.

## Declaration

```swift
func firstRect(for range: UITextRange) -> CGRect
```

## Parameters

- `range`: An object that represents a range of text in a document.

## Return Value

Return Value The first rectangle in a range of text. You might use this rectangle to draw a correction rectangle. The “first” in the name refers the rectangle enclosing the first line when the range encompasses multiple lines of text.

## See Also

### Related Documentation

- [caretRect(for:)](uikit/uitextinput/caretrect(for:).md)

### Working with geometry and hit-testing

- [closestPosition(to:)](uikit/uitextinput/closestposition(to:).md)
- [selectionRects(for:)](uikit/uitextinput/selectionrects(for:).md)
- [closestPosition(to:within:)](uikit/uitextinput/closestposition(to:within:).md)
- [characterRange(at:)](uikit/uitextinput/characterrange(at:).md)
