<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGRectGetWidth(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGRectGetWidth"
  },
  "title" : "CGRectGetWidth(_:)"
}
-->

# CGRectGetWidth(_:)

Returns the width of a rectangle.

```
func CGRectGetWidth(_ rect: CGRect) -> CGFloat
```

## Parameters

`rect`

The rectangle to examine.

## Return Value

The width of the specified rectangle.

## Discussion

Regardless of whether the width is stored in the <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> data structure as a positive or negative number, this function returns the width as if the rectangle were standardized.  That is, the result is never a negative number.

---

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)