<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIView/alignmentRect(forFrame:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIView(im)alignmentRectForFrame:"
  },
  "title" : "alignmentRect(forFrame:)"
}
-->

# alignmentRect(forFrame:)

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

```
func alignmentRect(forFrame frame: CGRect) -> CGRect
```

## Parameters

`frame`

The frame whose corresponding alignment rectangle is desired.

## Return Value

The alignment rectangle for the specified frame.

## 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 the view’s frame modified by the view’s [`alignmentRectInsets`](/documentation/UIKit/UIView/alignmentRectInsets). Most custom views can use  [`alignmentRectInsets`](/documentation/UIKit/UIView/alignmentRectInsets) to specify the location of their content within their frame. Custom views that require arbitrary transformations can override [`alignmentRect(forFrame:)`](/documentation/UIKit/UIView/alignmentRect(forFrame:)) and [`frame(forAlignmentRect:)`](/documentation/UIKit/UIView/frame(forAlignmentRect:)) to describe the location of their content. These two methods must always be inverses of each other.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)