Post

Replies

Boosts

Views

Activity

Reply to Unable to tap through a disabled SwiftUI View to a ViewController
Here is a hack which seems to work for me: struct NoHitTesting: ViewModifier {   func body(content: Content) -> some View {     SwiftUIWrapper { content }.allowsHitTesting(false)   } } extension View {   func userInteractionDisabled() -> some View {     self.modifier(NoHitTesting())   } } struct SwiftUIWrapper<T: View>: UIViewControllerRepresentable {   let content: () -> T   func makeUIViewController(context: Context) -> UIHostingController<T> {     UIHostingController(rootView: content())   }   func updateUIViewController(_ uiViewController: UIHostingController<T>, context: Context) {} } Which you can use like this to disable the background view for instance when it covers up a UIViewController, etc. Color.red.userInteractionDisabled()
Jul ’20