0

I was trying to hide statusBar of a view but I noticed it does not work in macOS, also Blur did not worked also opacity did not work! it look like I am trying programming new language, apple said code in place and apply every where! why I can not done those simple task in macOS?

struct ContentView: View {
    var body: some View {        
        HStack {
            Button { print("OK was clicked!") } label: { Text("OK").frame(width: 100) }
            Button { print("Close was clicked!") } label: { Text("Close").frame(width: 100) }
        }
        .frame(width: 400, height: 200)
        .background(Color.white.opacity(0.4).blur(radius: 0.5))
        //.statusBar(hidden: true)
    }
}

enter image description here

enter image description here

import SwiftUI

@main
struct macOSApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

1 Answers1

0

Hope it helps you.
Thank you.

class AppDelegate: NSObject, UIApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {

    // Create the content view, to display the contents
    let contentView = ContentView()
    //to display content view beyond status bar.
        .edgesIgnoringSafeArea(.top)  

    // Now, just create the window and set the content view. 
    window = NSWindow(
        contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
        styleMask: [.titled, .closable, .miniaturizable, .texturedBackground, .resizable, .fullSizeContentView],
        backing: .buffered, defer: false)
    window.center()
    window.setFrameAutosaveName("Main Window")
    
    //So, this does the maigc
    //Hides the titlebar.
    window.titlebarAppearsTransparent = true 
    window.titleVisibility = .hidden        

    window.contentView = NSHostingView(rootView: contentView)
    window.makeKeyAndOrderFront(nil)
}
}
Navemics
  • 51
  • 6
  • I do not see App Delegate in my project, I made a screenshot –  Nov 22 '20 at 10:37
  • In your, macOsApp.swift. you can the below line in the macosApp struct, `@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate` & add copy & paste the editted answer somewhere in that file. – Navemics Nov 22 '20 at 16:39
  • Can you explain more, I can not get it working or maybe a example –  Nov 22 '20 at 17:15