react-native - HitRect 如何在 React Native 中与 Pressable 一起使用?
问题描述
我们计划从 TouchableOpacity 切换到 Pressable。
我们希望使用 Pressable 的可选 HitRec 来确保我们的命中目标大小合适(我们将计算尺寸)以实现可访问性目的。
Pressable文档没有关于使用 HitRect 的信息。我在其他地方找到了对 HitRect 的引用,但它们也没有有用的信息。
谁能描述应该如何使用 Pressable 实现 HitRect?
解决方案
您可以使用 hitSlop 设置 HitRect,如下例所示
<Pressable
onPress={() => navigation.toggleDrawer()}
hitSlop = {50} // to increase the clickable area
>
Menu
</Pressable>
推荐阅读
- c# - C# MS Word 互操作性 - 如何拉伸填充表格中的最后一列
- python - 正确组合数据帧
- r - R - 底图功能 - 自定义轴
- python - Python Zeep 为肥皂请求引发未知错误
- sql-server - 无法从 SQL Server 发送带有查询结果的电子邮件
- sql - SQL - 根据日期时间创建一个不同的列表
- python-3.x - 如何在python中创建一个迭代器类,它将以相反的顺序遍历输入?
- django - 如何使用石墨烯突变信息访问 django 请求
- python - 使用官方网站的 CIFAR-10 数据集进行梯度爆炸
- node.js - AWS Lambda 在 50 毫秒内随机获取操作超时