SwiftUI NSTitlebarAccessoryViewController

Viewed 130

I'd like to use the SwiftUI app lifecycle, but my app uses NSTitlebarAccessoryViewController to show a bar of tool options below the toolbar:

toolbar

Specifically, I'm doing this:

        let toolSettingsView = NSHostingView(rootView: ToolAccessoryView(model: model))
        let vc = NSTitlebarAccessoryViewController()
        vc.view = toolSettingsView
        vc.fullScreenMinHeight = accessoryHeight // Ensure tool settings are visible in full screen.
        toolSettingsView.frame.size = toolSettingsView.fittingSize
        window?.addTitlebarAccessoryViewController(vc)

Is there a (practical) way I can mimic the control appearance (of the sliders, etc.) using pure SwiftUI? When use a SwiftUI view I get this:

enter image description here

Code looks like this:

struct MainView: View {
    
    var model: DataModel
    var undoManager: UndoManager
    
    var body: some View {
        VStack {
            ToolAccessoryView(model: model)
            SculptingView(model: model, undoManager: undoManager)
        }
    }
}
0 Answers
Related