---
title: "sizeThatFits(in:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/nshostingcontroller/sizethatfits(in:)"
---

# sizeThatFits(in:)

Calculates and returns the most appropriate size for the current view.

## Declaration

```swift
@MainActor @preconcurrency func sizeThatFits(in size: CGSize) -> CGSize
```

## Parameters

- `size`: The proposed new size for the view.

## Return Value

Return Value The size that offers the best fit for the root view and its contents.

## See Also

### Configuring the controller

- [preferredContentSize](swiftui/nshostingcontroller/preferredcontentsize.md)
- [sizingOptions](swiftui/nshostingcontroller/sizingoptions.md)
- [safeAreaRegions](swiftui/nshostingcontroller/safearearegions.md)
- [sceneBridgingOptions](swiftui/nshostingcontroller/scenebridgingoptions.md)
