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

# setConstrainedFrameSize(_:)

Attempts to set the frame size as if by user action.

```
func setConstrainedFrameSize(_ desiredSize: NSSize)
```

## Parameters

`desiredSize`

The new desired size.

## Discussion

This method respects the receiver’s existing minimum and maximum sizes and by whether resizing is permitted.

## See Also

[`var minSize: NSSize`](/documentation/AppKit/NSText/minSize)

The receiver’s minimum size.

[`var isVerticallyResizable: Bool`](/documentation/AppKit/NSText/isVerticallyResizable)

A Boolean that controls whether the receiver changes its height to fit the height of its text.

[`var isHorizontallyResizable: Bool`](/documentation/AppKit/NSText/isHorizontallyResizable)

A Boolean that controls whether the receiver changes its width to fit the width of its text.

[`var maxSize: NSSize`](/documentation/AppKit/NSText/maxSize)

The receiver’s maximum size.



---

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)