UIHostingController blocks all touches behind it. You basically have to choose SwiftUI, or UIKit? If you want a SwiftUI overlay over a UIKit view for example, you can't have that.
HostingPassthrough allows you to fix this by inheriting HostingParentController instead of UIViewController in the places where you will be adding SwiftUI views through UIHostingController.
- If you don't want to force your UIHostingControllers to have clear backgrounds, set
makeBackgroundsClear = falseinviewDidLoad(). - If you want to forward touches on the base view of the HostingParentController to another view, set
forwardBaseTouchesToto another UIView you want to handle your touches. - You can also now inherit or initalise a
HostingParentViewinstead ofUIView, in the case that you aren't adding theUIHostingControllerto a parent view controller. While you should always add theUIHostingControllerto a parent view controller if possible to correctly manage view lifecycle, there may be instances where you are for example adding SwiftUI components to a reusable custom UIView in which case usingHostingParentViewwould be acceptable. - If SwiftUI
ScrollViewis messing up your tap targets, you can setignoreTouchesOnSwiftUIScrollViewtotrueso any touches that reach the bottom of a SwiftUIScrollView(not the content), are passed to whatever is under it.
Some cool logic will then be applied overriding the hitTest method, which ignores any touches in parts of a UIHostingController that don't contain a SwiftUI view and pass it to whatever is underneath instead.
TODO:
- Fix SwiftUI
.contentShape()not working.
All these views are tappable, even behind the 3 UIHostingController's!

