---
title: sizeToFit()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nscontrol/sizetofit()
---

# sizeToFit()

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

## Declaration

```swift
func sizeToFit()
```

## Discussion

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 thedisplay() or setNeedsDisplay() method.

## See Also

### Related Documentation

- [calcSize()](appkit/nscontrol/calcsize().md)

### Resizing the Control

- [controlSize](appkit/nscontrol/controlsize-swift.property.md)
- [NSControl.ControlSize](appkit/nscontrol/controlsize-swift.enum.md)
- [sizeThatFits(_:)](appkit/nscontrol/sizethatfits(_:).md)
