https://github.com/boybeak/swiftuiwindow
Quick open a window with SwiftUI for macOS
https://github.com/boybeak/swiftuiwindow
Last synced: over 1 year ago
JSON representation
Quick open a window with SwiftUI for macOS
- Host: GitHub
- URL: https://github.com/boybeak/swiftuiwindow
- Owner: boybeak
- License: mit
- Created: 2024-08-21T05:05:02.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T16:20:40.000Z (almost 2 years ago)
- Last Synced: 2025-02-06T01:43:00.924Z (over 1 year ago)
- Language: Swift
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```swift
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"
}
}
```