如何仅对1个角使用边界半径(react-native)?

Mak*_*sim 58 javascript reactjs react-native

如何在React Native中仅使用1个角的边界半径?

我有一个模态窗口

http://f1.s.qip.ru/etSMz5YP.png

正如你可以看到底角没有圆角,当我使用backgroundColor按钮时会发生这种情况.我试图将溢出设置隐藏到模态包装器,它没有帮助我.现在我想使用边框半径到按钮(仅适用于1个角).

我的代码http://jsbin.com/sexeputuqe/edit?html,css

Mat*_*olo 186

你有没有试过以下?
- borderBottomLeftRadius:number
- borderBottomRightRadius:number
- borderTopLeftRadius:number
- borderTopRightRadius:number

此外,您还可以在视图组件文档中找到更多信息.

  • 尝试将`overflow:hidden`放到View(或Text)中.它应该工作. (13认同)
  • @kevin"Image"组件的iOS版本[忽略角落特定半径设置](http://facebook.github.io/react-native/releases/0.42/docs/images.html#ios-border-radius-styles ).在某些情况下,您可以使用负边距"掩盖"您不想要圆角的角落. (8认同)
  • 在IOS上对我不起作用.只有`borderRadius`才能工作,但是对所有角都应用半径 (7认同)
  • 是的,我正在尝试,但没有效果. (3认同)

小智 15

  • borderBottomLeftRadius:数字
  • borderBottomRightRadius:数字
  • borderTopLeftRadius:数字
  • borderTopRightRadius:数字

这对我有用.

谢谢

  • 它只适用于android,而不适用于IOS (5认同)

小智 7

假设只为Image标签的左上角和左下角设置了半径。

<View style={styles.imgBox}>
  <Image source={{ uri: 'your image url' }} style={styles.img} />
</View>

 const styles = EStyleSheet.create({
 imgBox: {
       width: px(72),
       height: px(72),
       borderBottomLeftRadius: 2,
       borderTopLeftRadius: 2,
       overflow: 'hidden',
 },
 img: {
       width: px(72),
       height: px(72),
  },
})
Run Code Online (Sandbox Code Playgroud)

对于ios来说看起来不错。