---
title: "clearButtonRect(forBounds:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextfield/clearbuttonrect(forbounds:)"
---

# clearButtonRect(forBounds:)

Returns the drawing rectangle for the built-in Clear button.

## Declaration

```swift
func clearButtonRect(forBounds bounds: CGRect) -> CGRect
```

## Parameters

- `bounds`: The bounding rectangle of the receiver.

## Return Value

Return Value The rectangle in which to draw the clear button.

## Discussion

Discussion You should not call this method directly. If you want to place the clear button in a different location, you can override this method and return the new rectangle. Your method should call the super implementation and modify the returned rectangle’s origin only. Changing the size of the clear button may cause unnecessary distortion of the button image.

## See Also

### Drawing and positioning overrides

- [textRect(forBounds:)](uikit/uitextfield/textrect(forbounds:).md)
- [drawText(in:)](uikit/uitextfield/drawtext(in:).md)
- [placeholderRect(forBounds:)](uikit/uitextfield/placeholderrect(forbounds:).md)
- [drawPlaceholder(in:)](uikit/uitextfield/drawplaceholder(in:).md)
- [borderRect(forBounds:)](uikit/uitextfield/borderrect(forbounds:).md)
- [editingRect(forBounds:)](uikit/uitextfield/editingrect(forbounds:).md)
- [leftViewRect(forBounds:)](uikit/uitextfield/leftviewrect(forbounds:).md)
- [rightViewRect(forBounds:)](uikit/uitextfield/rightviewrect(forbounds:).md)
