I'm trying to create the background for a background view for a popup, however the view doesn't cover the bottom even after I use .ignoreSafeArea().
import SwiftUI
struct Overlay<Content: View>: View {
@State var opacity: Double = 0
var content: Content
var body: some View {
VStack {
Color.black.opacity(opacity).ignoresSafeArea()
content
}
.onAppear { self.opacity = 0.5 }
.onDisappear { self.opacity = 0 }
}
}
struct ForgotPasswordView_Previews: PreviewProvider {
static var previews: some View {
Group {
Overlay(content: Text(""))
.previewDevice("iPhone 12")
}
}
}

VStack arranges its children in a vertical line.
What You see in the bottom area is your content which you pass in the view creation (here its your TextView).
struct Overlay<Content: View>: View {
@State var opacity: Double = 0
var content: Content
var body: some View {
ZStack { //<- here
Color.black.opacity(opacity).ignoresSafeArea()
content
}
.onAppear { self.opacity = 0.5 }
.onDisappear { self.opacity = 0 }
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With