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

# addFloatingSubview(_:for:)

Adds a floating subview to the document view.

```
func addFloatingSubview(_ view: NSView, for axis: NSEvent.GestureAxis)
```

## Parameters

`view`

The view that can float.

`axis`

The event gesture axis on which the view can float. A view can float on only one axis at a time.

## Discussion

Floating subviews of the document view do not scroll like the rest of the document. Instead these views appear to float over the document. For example, see `NSTableView` floating group rows ([`floatsGroupRows`](/documentation/AppKit/NSTableView/floatsGroupRows)).

`NSScrollView` ensures that any scrolling on the non-floating axis is performed visually synchronously with the document content.

> Note:
> You are responsible for keeping track of the floating views and removing them via ``doc://com.apple.appkit/documentation/AppKit/NSView/removeFromSuperview()`` when they should no longer float.

---

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)