当我在下面所示的弧上按任意位置时,在Android上,总是正确调用onPress,但在iOS上,有时会调用onPress,但有时却没有。弧的某些部分在iOS上不可单击。
此外,弧上没有任何定位元素(绝对/相对定位)。
这是我的代码。
<Svg
height={deviceHeight - 200}
width={deviceWidth}
>
<Path
ref={ref => this.pathRef = ref}
fill="none"
stroke='rgba(214,51,51,.2)'
strokeWidth={35}
onPress={() => console.log('path on pressed called!')}
d="M 392.72727272727275 124.90909090909088 A 360 450 0 0 0 42.72727272727275 574.9090909090909"
/>
</Svg>
我还在react-native-svg软件包中记录了一个问题:https://github.com/react-native-community/react-native-svg/issues/1256
在react-native-svg中,您可以使用“ Symbol”组件,它将所有元素分组为一个元素,然后将onPress()添加到该符号。它将适用于所有绝对/相对内容。
<Svg height="150" width="110">
<Symbol id="symbol" viewBox="0 0 150 110" width="100" height="50">
//------------------------------
// Your content for that arc
//------------------------------
</Symbol>
</Svg>