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

# magnify(toFit:)

Magnifies the content view proportionally such that the given rectangle fits centered in the scroll view.

```
func magnify(toFit rect: NSRect)
```

## Parameters

`rect`

The rectangle (in content view space) to which the content view is magnified.

## Discussion

The resulting magnification value is clipped to the [`minMagnification`](/documentation/AppKit/NSScrollView/minMagnification) and [`maxMagnification`](/documentation/AppKit/NSScrollView/maxMagnification) values. To animate the magnification, use the object’s animator.

---

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)