---
title: "frame(forAlignmentRect:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiview/frame(foralignmentrect:)"
---

# frame(forAlignmentRect:)

Returns the view’s frame for a given alignment rectangle.

## Declaration

```swift
func frame(forAlignmentRect alignmentRect: CGRect) -> CGRect
```

## Parameters

- `alignmentRect`: The alignment rectangle whose corresponding frame is desired.

## Return Value

Return Value The frame for the specified alignment rectangle

## Discussion

Discussion The constraint-based layout system uses alignment rectangles to align views, rather than their frame. This allows custom views to be aligned based on the location of their content while still having a frame that encompasses any ornamentation they need to draw around their content, such as shadows or reflections. The default implementation returns alignmentRect modified by the view’s alignmentRectInsets. Most custom views can override alignmentRectInsets to specify the location of their content within their frame. Custom views that require arbitrary transformations can override alignmentRect(forFrame:) and frame(forAlignmentRect:) to describe the location of their content. These two methods must always be inverses of each other.

## See Also

### Aligning views in Auto Layout

- [alignmentRect(forFrame:)](uikit/uiview/alignmentrect(forframe:).md)
- [alignmentRectInsets](uikit/uiview/alignmentrectinsets.md)
- [forFirstBaselineLayout](uikit/uiview/forfirstbaselinelayout.md)
- [forLastBaselineLayout](uikit/uiview/forlastbaselinelayout.md)
