Skip to content

boybeak/SwiftUIWindow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUIWindow

Quick open a window with SwiftUI for macOS

Installation

Open XCode, File -> Add Package Denpendencies -> Search https://github.com/boybeak/SwiftUIWindow.git -> Add Package.

Usage

import SwiftUIWindow

struct ContentView : View {

    var body: some View {
        Button(
            action: {
                openWindow()
            }
        ) {
            Text("Open Window")
        }
    }
    
    func openWindow() {
        let window = openSwiftUIWindow { win in
            ZStack {
                Button(
                    action: {
                        win.close()
                    }
                ) {
                    Text("Close Window")
                }
            }
            .frame(width: 256, height: 256)
        }
        
        // You can config window here
        window.center()
        window.title = "Demo window"
    }
}

About

Quick open a window with SwiftUI for macOS

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages