@@ -40,6 +40,7 @@ @interface RCTRootContentView : RCTView <RCTInvalidating>
4040
4141@property (nonatomic , readonly ) BOOL contentHasAppeared;
4242@property (nonatomic , readonly , strong ) RCTTouchHandler *touchHandler;
43+ @property (nonatomic , assign ) BOOL passThroughTouches;
4344
4445- (instancetype )initWithFrame : (CGRect)frame
4546 bridge : (RCTBridge *)bridge
@@ -125,6 +126,16 @@ - (void)setBackgroundColor:(UIColor *)backgroundColor
125126 _contentView.backgroundColor = backgroundColor;
126127}
127128
129+ - (BOOL )passThroughTouches
130+ {
131+ return _contentView.passThroughTouches ;
132+ }
133+
134+ - (void )setPassThroughTouches : (BOOL )passThroughTouches
135+ {
136+ _contentView.passThroughTouches = passThroughTouches;
137+ }
138+
128139- (UIViewController *)reactViewController
129140{
130141 return _reactViewController ?: [super reactViewController ];
@@ -259,6 +270,16 @@ - (void)layoutSubviews
259270 };
260271}
261272
273+ - (UIView *)hitTest : (CGPoint)point withEvent : (UIEvent *)event
274+ {
275+ // The root view itself should never receive touches
276+ UIView *hitView = [super hitTest: point withEvent: event];
277+ if (self.passThroughTouches && hitView == self) {
278+ return nil ;
279+ }
280+ return hitView;
281+ }
282+
262283- (void )setAppProperties : (NSDictionary *)appProperties
263284{
264285 RCTAssertMainQueue ();
@@ -382,6 +403,16 @@ - (UIColor *)backgroundColor
382403 return _backgroundColor;
383404}
384405
406+ - (UIView *)hitTest : (CGPoint)point withEvent : (UIEvent *)event
407+ {
408+ // The root content view itself should never receive touches
409+ UIView *hitView = [super hitTest: point withEvent: event];
410+ if (_passThroughTouches && hitView == self) {
411+ return nil ;
412+ }
413+ return hitView;
414+ }
415+
385416- (void )invalidate
386417{
387418 if (self.userInteractionEnabled ) {
0 commit comments