An AppKit view that hosts a SwiftUI view hierarchy.
SDKs
- macOS 10.15+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
Overview
You use NSHosting
objects to integrate SwiftUI views into your AppKit view hierarchies. A hosting view is an NSView
object that manages a single SwiftUI view, which may itself contain other SwiftUI views. Because it is an NSView
object, you can integrate it into your existing AppKit view hierarchies to implement portions of your UI. For example, you can use a hosting view to implement a custom control.
A hosting view acts as a bridge between your SwiftUI views and your AppKit interface. During layout, the hosting view reports the content size preferences of your SwiftUI views back to the AppKit layout system so that it can size the view appropriately. The hosting view also coordinates event delivery.