You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native中Gorhom Bottom Sheet背景置灰失效问题求助

解决gorhom bottom-sheet打开时背景未变灰色的问题

要实现底部弹窗打开时背景变为灰色,你需要补充两个关键配置:

  • 开启背景遮罩:添加enableBackdrop属性并设为true(该属性默认处于关闭状态)
  • 自定义遮罩样式:通过backdropStyle设置背景的颜色与透明度,匹配你的预期效果

修改后的代码示例:

<BottomSheet
  ref={sheetRef}
  snapPoints={snapPoints}
  onCloseEnd={handleClosePress}
  enableBackdrop={true} // 开启背景遮罩
  backdropStyle={{ backgroundColor: 'rgba(0, 0, 0, 0.5)' }} // 自定义灰色半透明背景
>
  <BottomSheetView style={styles.modalContainer}>
    ////////some content
  </BottomSheetView>
</BottomSheet>

// 原有样式保持不变
modalContainer: {
  width: "100%"
},

如果需要点击背景关闭弹窗的交互,可以额外添加enableBackgroundDismiss={true},点击遮罩区域即可触发弹窗关闭。

内容的提问来源于stack exchange,提问作者med hedi ben salah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 12:02:33