Is there a way to configure the style and toolbar of the macOS window that Xcode uses in #Preview
?
I am working on a macOS application and want to preview some SwiftUI views within different window styles, toolbar styles and window title/subtitle visibilities.
Some of the modifiers to control the look-and-feel of a window are actually Scene Modifiers, not View Modifiers:
.windowStyle
.windowToolbarLabelStyle
.windowToolbarStyle
But #Preview
does not accept Scenes
, so I can't apply these modifiers:
// Error, not a view modifier.
#Preview {
ContentView()
.windowStyle(...)
}
// Error, Window is not supported in #Preview.
#Preview {
Window("Browser", id: "browser") {
ContentView()
}
}
If I give my ContentView a .toolbar(...)
, Xcode's Preview will correctly show a window with a toolbar, but not necessarily in the style I want.
Is there a way to apply the Scene Modifiers to #Preview
so that I can see how they affect the window's chrome and toolbar?