Post

Replies

Boosts

Views

Activity

Reply to Transparent window in SwiftUI macOS application
I tried the last solution, but the titlebar is opaque with this code: struct VisualEffect: NSViewRepresentable {   func makeNSView(context: Self.Context) -> NSView { return NSVisualEffectView() }   func updateNSView(_ nsView: NSView, context: Context) { } } @main struct MyApp: App {     var body: some Scene {         #if os(macOS)             WindowGroup {                 ContentView()                     .background(VisualEffect()) }             .windowStyle(.hiddenTitleBar)         #endif     } } Seems complicated to render the hidden title bar translucent
Jun ’22
Reply to Transparent window in SwiftUI macOS application
Ok thank You Mikeyh. You resolved two things in one I was .ignoresafearea() on the ContextView() so the bar was transparent but a small goofy part at the bottom, ( the size of a title bar) was background color but not translucent, weird! You resolved this. Thanks I still have one more surely stupid question: ok the background of the window is now transparent, but only when the window has been put to front and activated(if it looses focus the background color is the system background color and no more transparent) Thank you for your time mikeyh
Jun ’22
Reply to Transparent window in SwiftUI macOS application
finally settled for this: import SwiftUI // Visual effect est la pour rendre le fond effet transparent struct VisualEffect: NSViewRepresentable {   func makeNSView(context: Self.Context) -> NSView {       var test = NSVisualEffectView()       test.state = NSVisualEffectView.State.active // this is this state which says transparent all of the time       return test }   func updateNSView(_ nsView: NSView, context: Context) { } }
Jun ’22
Reply to Transparent window in SwiftUI macOS application
better use let and not var for "test" and Yes @mikeyh I finally read the documentation ;) finally settled for this: import SwiftUI // Visual effect est la pour rendre le fond effet transparent struct VisualEffect: NSViewRepresentable {   func makeNSView(context: Self.Context) -> NSView {       let test = NSVisualEffectView()       test.state = NSVisualEffectView.State.active // this is this state which says transparent all of the time       return test }   func updateNSView(_ nsView: NSView, context: Context) { } }
Jun ’22