How do I make a UIViewRepresentable beneath SwiftUI elements ignore touches to these elements?

Hello, and an early "Merry Christmas" to all,

I'm building a SwiftUI app, and one of my Views is a fullscreen UIViewRepresentable (SpriteView) beneath a SwiftUI interface.

Whenever the user interacts with any SwiftUI element, the UIView registers a hit in touchesBegan(). For example, my UIView has logic for pinching (not implemented via UIGestureRecognizer), so whenever the user holds down a SwiftUI element while touching the UIView, that counts as two touches to the UIView which invokes the pinching logic.

Things I've tried to block SwiftUI from passing the gesture down to the UIView:

  1. Adding opaque elements beneath control elements
  2. Adding gestures to the elements above
  3. Adding gesture masks to the gestures above
  4. Converting eligible elements to Buttons (since those seem immune)
  5. Adding SpriteViews beneath those elements to absorb gestures

So far nothing has worked. As long as the UIView is beneath SwiftUI elements, any interactions with those elements will be registered as a hit.

The obvious solution is to track each SwiftUI element's size and coordinates with respect to the UIView's coordinate space, then use exclusion areas, but this is both a pain and expensive, and I find it hard to believe this is the best fix for such a seemingly basic problem.

I'm probably overlooking something basic, so any suggestions will be greatly appreciated

How do I make a UIViewRepresentable beneath SwiftUI elements ignore touches to these elements?
 
 
Q