Skip to content

mortenjust/SwiftUIWindow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUIWindow

Open a new macOS (10.12+) window with SwiftUI contents. Note: macOS Ventura (fall 2022) has new ways of creating windows from SwiftUI.

Installing

Paste this repo's URL into your Package Dependencies

Demo

Creating a SwiftUI image

Usage

import SwiftUIWindow

Simple standard window

  SwiftUIWindow.open { _ in 
        Text("Hello new window")
        .frame(width: 400, height: 200) // window size        
    }                                

Using modifiers

This will open a floating window with no standard macOS window UI. You can move the window by dragging anywhere in the visible area.

  SwiftUIWindow.open { _ in 
        VStack { 
            Text("Hello")
            Button("Click me") { print("clicked") }
        }
        .frame(minWidth: 400, maxWidth: .infinity, minHeight: 200, maxHeight: .infinity)                     
    }                
    .style(.borderless)
    .clickable(true)
    .mouseMovesWindow(true)
    .transparentBackground(true)
    .alwaysOnTop(true)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages