React Native:透明视图后面的按钮

React Native: Button behind transparent view

出于布局目的,我在 React Native 应用程序的视图顶部渲染了多张图像。这些图像位于屏幕的顶部、左侧和右侧边界。它们包含在具有透明背景的 View 组件中。

这意味着屏幕的所有内容都在 View 组件后面。我遇到的问题是我现在无法触摸我的任何实际内容,因为它被透明 View

问题:如何在 React-Native 中触摸透明视图后面的组件?

我不是第一个处理这个问题的人,但它在网上的记录似乎很少

一个简单的解决方案是将 pointerEvents 设置为 none 用于透明 View:

<View pointerEvents="none">
  {/* your corner images */}
</View>

来自MDN的定义:

In addition to indicating that the element is not the target of mouse events, the value none instructs the mouse event to go "through" the element and target whatever is "underneath" that element instead.

其他资源: