首页 > 解决方案 > 反应带有边框的原生圆形图像

问题描述

我想创建一个带边框的圆形图像。如果我添加borderColor: 'green', borderWidth:1,边框仅在圆形图像的左上角可见。

在此处输入图像描述

<TouchableHighlight
          style={[styles.profileImgContainer, { borderColor: 'green', borderWidth:1 }]}
        >
    <Image source={{ uri:"https://www.t-nation.com/system/publishing/articles/10005529/original/6-Reasons-You-Should-Never-Open-a-Gym.png" }} style={styles.profileImg} />
</TouchableHighlight>

export default styles = StyleSheet.create({
  profileImgContainer: {
    marginLeft: 8,
    height: 80,
    width: 80,
    borderRadius: 40,
  },
  profileImg: {
    height: 80,
    width: 80,
    borderRadius: 40,
  },
});

标签: react-native

解决方案


overflow: 'hidden'图像容器解决了这个问题。


推荐阅读