如何将borderRadius 添加到ImageBackground?

新手上路,请多包涵

React Native ImageBackground 组件应该接受与 Image 相同的 prop 签名。但是,它似乎不接受 borderRadius

这没有影响。

 <ImageBackground
  style={{height: 100, width: 100, borderRadius: 6}}
  source={{ uri: 'www.imageislocatedhere.com }}
>

如何更改 ImageBackground 的边界半径?

原文由 GollyJer 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 562
1 个回答

这需要一些挖掘,因此发布问答以供其他人查找。

ImageBackground 基本上是一个 <View> 包装一个 <Image>

style 道具仅将高度和宽度传递给 <Image>

要通过其他 style 道具使用 imageStyle

 <ImageBackground
  style={{height: 100, width: 100}}
  imageStyle={{ borderRadius: 6}}
  source={{ uri: 'www.imageislocatedhere.com }}
>

详细信息记录在源代码 中。

原文由 GollyJer 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题