---
title: "CGRectApplyAffineTransform(_:_:)"
framework: coregraphics
role: symbol
role_heading: Function
path: "coregraphics/cgrectapplyaffinetransform(_:_:)"
---

# CGRectApplyAffineTransform(_:_:)

Applies an affine transform to a rectangle.

## Declaration

```swift
func CGRectApplyAffineTransform(_ rect: CGRect, _ t: CGAffineTransform) -> CGRect
```

## Parameters

- `rect`: The rectangle whose corner points you want to transform.
- `t`: The affine transform to apply to the rect parameter.

## Return Value

Return Value The transformed rectangle.

## Discussion

Discussion Because affine transforms do not preserve rectangles in general, this function returns the smallest rectangle that contains the transformed corner points of the rect parameter. If the affine transform t consists solely of scaling and translation operations, then the returned rectangle coincides with the rectangle constructed from the four transformed corners.

## See Also

### Applying Affine Transformations

- [CGPointApplyAffineTransform(_:_:)](coregraphics/cgpointapplyaffinetransform(_:_:).md)
- [CGSizeApplyAffineTransform(_:_:)](coregraphics/cgsizeapplyaffinetransform(_:_:).md)
