---
title: View Hierarchy
framework: appkit
role: collectionGroup
role_heading: API Collection
path: appkit/view-hierarchy
---

# View Hierarchy

Manage the subviews, superview, and window of a view and respond to notifications when the view hierarchy changes.

## Topics

### Getting the Related Objects

- [superview](appkit/nsview/superview.md)
- [subviews](appkit/nsview/subviews.md)
- [window](appkit/nsview/window.md)
- [opaqueAncestor](appkit/nsview/opaqueancestor.md)
- [isDescendant(of:)](appkit/nsview/isdescendant(of:).md)
- [ancestorShared(with:)](appkit/nsview/ancestorshared(with:).md)
- [enclosingMenuItem](appkit/nsview/enclosingmenuitem.md)
- [enclosingScrollView](appkit/nsview/enclosingscrollview.md)

### Adding and Removing Subviews

- [addSubview(_:)](appkit/nsview/addsubview(_:).md)
- [addSubview(_:positioned:relativeTo:)](appkit/nsview/addsubview(_:positioned:relativeto:).md)
- [removeFromSuperview()](appkit/nsview/removefromsuperview().md)
- [removeFromSuperviewWithoutNeedingDisplay()](appkit/nsview/removefromsuperviewwithoutneedingdisplay().md)
- [replaceSubview(_:with:)](appkit/nsview/replacesubview(_:with:).md)
- [sortSubviews(_:context:)](appkit/nsview/sortsubviews(_:context:).md)

### Responding to View-Related Notifications

- [didAddSubview(_:)](appkit/nsview/didaddsubview(_:).md)
- [viewDidMoveToSuperview()](appkit/nsview/viewdidmovetosuperview().md)
- [viewDidMoveToWindow()](appkit/nsview/viewdidmovetowindow().md)
- [viewWillMove(toSuperview:)](appkit/nsview/viewwillmove(tosuperview:).md)
- [viewWillMove(toWindow:)](appkit/nsview/viewwillmove(towindow:).md)
- [willRemoveSubview(_:)](appkit/nsview/willremovesubview(_:).md)

### Identifying Views by Tag

- [viewWithTag(_:)](appkit/nsview/viewwithtag(_:).md)
- [tag](appkit/nsview/tag.md)

## See Also

### Configuring the view

- [View Coordinates](appkit/view-coordinates.md)
- [Appearance](appkit/nsview-appearance.md)
- [Core Animation Support](appkit/core-animation-support.md)
- [Related UI](appkit/related-ui.md)
