The window and toolbar style can be defined with the windowStyle() and windowToolbarStyle() modifiers for the WindowGroup in the main app struct. Some of the styles are demonstrated below.
This example shows the default window and toolbar styles.
import SwiftUI
@main
struct WindowStyleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.automatic)
.windowToolbarStyle(.automatic)
}
}
A window with a unified compact toolbar is shown below.
import SwiftUI
@main
struct WindowStyleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.automatic)
.windowToolbarStyle(.unifiedCompact)
}
}
Lastly, a window with a hidden title bar and a unified compact toolbar is demonstrated.
import SwiftUI
@main
struct WindowStyleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.hiddenTitleBar)
.windowToolbarStyle(.unifiedCompact)
}
}
Gavin Wiggins © 2024