I want to block tapping views in background of my modal transition popup. How can I achieve this in swiftUI? (my example modal transition https://youtube.com/shorts/9GT1xNlzCiE?feature=share)
CodePudding user response:
You can add .disabled(Bool)
in your background view with a @State Boolean variable. As-
struct HomePageSwiftUIView: View {
@State private var isModalShowing: Bool = false
var body: some View {
VStack() {
// Your background view
}
.disabled(isModalShowing)
VStack() {
// Your background view
}
.disabled(isModalShowing)
VStack() {
// Your popup view (Dont add it)
}
}
}
While clicking alert button just set isModalShowing = true
and also isModalShowing = false
when alert dismissed.