---
title: "addFloatingSubview(_:for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsscrollview/addfloatingsubview(_:for:)"
---

# addFloatingSubview(_:for:)

Adds a floating subview to the document view.

## Declaration

```swift
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

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). 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 removeFromSuperview() when they should no longer float.

## See Also

### Managing the Views

- [contentView](appkit/nsscrollview/contentview.md)
- [documentView](appkit/nsscrollview/documentview.md)
