Skip to content

Instantly share code, notes, and snippets.

@chriseidhof
Created September 26, 2022 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseidhof/ad9b4a5776f5e88f11d51b1908a697a1 to your computer and use it in GitHub Desktop.
Save chriseidhof/ad9b4a5776f5e88f11d51b1908a697a1 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// OverlayTest
//
// Created by Chris Eidhof on 26.09.22.
//
import SwiftUI
struct ContentView: View {
@State var visible = false
@State var sheet = false
var body: some View {
TabView {
Button("Show Sheet") { sheet.toggle() }
.sheet(isPresented: $sheet, content: {
Button("Show Overlay") {
visible.toggle()
}
})
}
.overlay {
if visible {
Color.secondary.edgesIgnoringSafeArea(.all)
.overlay {
Text("OVERLAY")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment