首页 > 解决方案 > 我怎样才能在所有方面都显示卡片阴影?

问题描述

我有以下风格

    card: {
      backgroundColor: Colors.white,
      borderRadius: 10,
      marginRight: Metrics.WIDTH*0.02,
      marginLeft: Metrics.WIDTH*0.02,
      borderColor: Colors.SILVER,
      borderWidth: 2,
      shadowColor: 'gray',
      shadowOffset: { width: 2, height: 2 },
      shadowOpacity: 0.5,
      shadowRadius: 2,
      elevation: 10,
    },

上述样式仅在右侧和底部创建阴影。如何平等地创造全方位的对决

在此处输入图像描述

标签: reactjsreact-nativereact-native-androidreact-native-ios

解决方案


你不能在 React-Native 中添加多个阴影。但是有一个解决方法。

widthand heightofshadowOffset设置为零,然后尝试更改shadowRadius,直到您对结果满意为止。

  card:{
    shadowOffset: { width: 0, height:0 },
    shadowOpacity: 0.5,
    shadowRadius: 10,
}

这是结果。

在此处输入图像描述


推荐阅读