React native React本机图像映射器(如何在图像上创建可触摸区域)
如何在图像上创建可触摸区域[单击位置1显示效果,在另一个位置2、3、4、5上显示相同效果和不同效果。] 实际上,当我点击图像上的特定位置时,会得到相应的x和y坐标,但不会得到图像上的可触摸区域 我们必须创建一个与此类似的映射对象React native React本机图像映射器(如何在图像上创建可触摸区域),react-native,React Native,如何在图像上创建可触摸区域[单击位置1显示效果,在另一个位置2、3、4、5上显示相同效果和不同效果。] 实际上,当我点击图像上的特定位置时,会得到相应的x和y坐标,但不会得到图像上的可触摸区域 我们必须创建一个与此类似的映射对象 const MAPPING = [ { id: '0', name: 'First Area Name', shape: 'rectangle', width: 30, height: 40, x1: 80,
const MAPPING = [
{
id: '0',
name: 'First Area Name',
shape: 'rectangle',
width: 30,
height: 40,
x1: 80,
y1: 500,
prefill: 'red',
fill: 'blue'
},
{
id: '1',
name: 'Second Area Name',
shape: 'rectangle',
x2: 155,
y2: 540,
x1: 125,
y1: 500
},
]
图像映射器的使用
<ImageMapper
imgHeight={500}
imgWidth={250}
imgSource={imageSource}
imgMap={MAPPING}
onPress={(item, idx, event) => this.onAnyAreaPress(item, idx, event)}
containerStyle={styles.myCustomStyle}
selectedAreaId="my_area_id"
/>
this.onAnyAreaPress(item,idx,event)}
containerStyle={styles.myCustomStyle}
selectedreaid=“我的\u区域\u id”
/>
它根据我们通过的映射提供了接触点。
请查看此文档以了解更多信息。