Custom Overlay View not Dismissing on iOS 17 when using SwiftUI with UIKit Integration
I'm wondering if anyone has experience with I'm experimenting with I've encountered a strange issue with I've been struggling with this for a few days now and could really use some help... Quick question that's been bugging me - I'm working with an scenario with a custom overlay view that I've implemented using SwiftUI in my iOS 17 app, which integrates some UIKit components. The overlay view is supposed to dismiss when tapping outside of it, but it doesn't seem to respond properly to the taps. I have set up a `UIViewControllerRepresentable` to wrap a UIKit view controller and integrate it with SwiftUI. The code for my overlay view looks like this: ```swift struct OverlayView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIHostingController<ContentView> { let hostingController = UIHostingController(rootView: ContentView()) return hostingController } func updateUIViewController(_ uiViewController: UIHostingController<ContentView>, context: Context) { // Update logic if needed } } struct ContentView: View { @Binding var isPresented: Bool var body: some View { ZStack { Color.black.opacity(0.5) .onTapGesture { isPresented = false } VStack { Text("Overlay Content") } .frame(width: 300, height: 200) .background(Color.white) .cornerRadius(10) } } } ``` I initialize `isPresented` as `true` to show the overlay. However, tapping the black area outside the overlay doesnβt dismiss it, and I don't see any behavior messages in the console. Iβve also tried adding a `UITapGestureRecognizer` in the `makeUIViewController` method, but that didn't help either. Based on my understanding, the `onTapGesture` should work, but it seems like the overlay view isn't capturing the touch events as expected. Is there a specific way to handle touch events in this scenario when wrapping UIKit with SwiftUI? I would appreciate any insights or solutions to properly dismiss the overlay view when tapping outside of it. Is there a better approach? I'd really appreciate any guidance on this. What's the best practice here? This is for a microservice running on Linux. Any feedback is welcome! The stack includes Swift and several other technologies. Any ideas what could be causing this?