Skip to content

WindowOverlay is a Swift package that provides an easy way to add overlay views to your SwiftUI application's window.

License

Notifications You must be signed in to change notification settings

sunghyun-k/swiftui-window-overlay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WindowOverlay

WindowOverlay is a Swift package that provides a convenient way to add overlay views to your SwiftUI application's window. This package is designed to work seamlessly with SwiftUI, offering a flexible solution for displaying content above your main app interface.

Features

  • Easy integration with SwiftUI
  • Customizable overlay content
  • Transparent hit-testing for non-interactive overlays

Usage

To use WindowOverlay in your SwiftUI view, simply apply the windowOverlay modifier:

struct ContentView: View {
  @State private var showOverlay = false
    
  var body: some View {
    VStack {
      Button("Show Overlay") {
        showOverlay.toggle()
     }
  }
  .windowOverlay(isPresented: showOverlay) {
    Text("This is an overlay")
      .padding()
      .background(Color.white)
      .cornerRadius(10)
    }
  }
}

How it works

WindowOverlay uses a combination of SwiftUI and UIKit to create a seamless overlay experience:

  1. The windowOverlay modifier is applied to your SwiftUI view.
  2. A WindowBridgingView is created to bridge between SwiftUI and UIKit.
  3. A custom WindowOverlayWindow is created and added to the app's window hierarchy.
  4. The overlay content is rendered in the custom window, appearing above the main app content.

Requirements

  • iOS 13.0+
  • Swift 5.9+

About

WindowOverlay is a Swift package that provides an easy way to add overlay views to your SwiftUI application's window.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages