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

# convertToDeviceSpace(_:)

Returns a rectangle that is transformed from user space coordinate to device space coordinates.

```
func convertToDeviceSpace(_ rect: CGRect) -> CGRect
```

## Parameters

`rect`

The rectangle, in user space coordinates, to transform.

## Return Value

The rectangle in device space coordinates.

## Discussion

In general affine transforms do not preserve rectangles. As a result, this function returns the smallest rectangle that contains the transformed corner points of the rectangle.

---

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)