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,
y1: 500,
prefill: 'red',
fill: 'blue'
},
{
id: '1',
name: 'Second Area Name',
shape: 'rectangle',
x2: 155,
y2: 540,
x1: 125,
y1: 500
},
]
ImageMapper 的使用
<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"
/>
它根据我们传递的映射提供接触点。请通过此文档了解更多信息。 图书馆
推荐阅读
- cordova - 使用cordova打包apk文件时,为什么会出现这个错误
- mongodb - express + mongoose 只返回 id
- python - 从 Excel 多页文件解析:列之间的列表理解
- dialogflow-es - 代理适用于 Dialogflow,但不适用于 Actions on Google
- linkedin - 如何为我的 Linkedin UGCPost(视频)帖子获取分析数据(点击次数、展示次数等)?
- amazon-web-services - 通过 ALB 和 Lambda 集成提供二进制响应
- javascript - javascript中密码的正则表达式
- c++ - c++二叉搜索树程序程序运行但结果不显示
- javafx - CSS 错误解析(预期 LBRACE 在 [1,9] )
- kotlin - Fabric.io 上传不适用于 crashlytics 和 kotlin