Home > Mobile >  How can make my Window size be big as Screen of mac?
How can make my Window size be big as Screen of mac?

Time:02-22

I am using this code for help Xcode to build my Window Size as big as the screen of mac, but it does not get maxed! How we can read the size of screen and set it for view size for taking all available space on screen? It would be great getting a SwiftUI approach for the issue.

struct ContentView: View {

    var body: some View {
        
        Color.purple
            .frame(maxWidth: .infinity, maxHeight: .infinity)

    }
    
}

CodePudding user response:

    let screenSize = NSScreen.main?.frame.size ?? CGSize(width: 800, height: 600)
    
    Color.purple
        .frame(width: screenSize.width, height: screenSize.height)
  • Related