<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSControl/sizeToFit()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSControl(im)sizeToFit"
  },
  "title" : "sizeToFit()"
}
-->

# sizeToFit()

Resizes the receiver’s frame so that it’s the minimum size needed to contain its cell.

```
func sizeToFit()
```

## Discussion

If you want a multiple-cell custom subclass of `NSControl` to size itself to fit its cells, you must override this method. This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with either the[`display()`](/documentation/AppKit/NSView/display()) or [`setNeedsDisplay()`](/documentation/AppKit/NSControl/setNeedsDisplay()) method.

## See Also

[`calcSize()`](/documentation/AppKit/NSControl/calcSize())

Recomputes any internal sizing information for the receiver, if necessary.



---

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)