如标题所述,在React Native中,我们如何设置视图的单侧阴影,或隐藏任何一侧的阴影? 我想要的是只显示一个侧面的阴影,有什么解决方案吗?
如标题所述,在React Native中,我们如何设置视图的单侧阴影,或隐藏任何一侧的阴影? 我想要的是只显示一个侧面的阴影,有什么解决方案吗?
使用这个
const style = {
shadowColor: "#000000",
shadowOffset: { width: 0, height: 2 }, // change this for more shadow
shadowOpacity: 0.4,
shadowRadius: 6,
}
例如:
shadowOffset: { width: 0, height: 10 }
阴影仅出现在视图底部
shadowOffset: { width: 0, height: -10 }
阴影仅出现在视图顶部
shadowOffset: { width: 10, height: 0 }
阴影仅出现在视图右侧
shadowOffset: { width: -10, height: 10 }
阴影仅出现在视图左侧
<LinearGradient start={{ x: 1, y: 0 }} end={{ x: 1, y: 1 }} colors={['#e4e2e4', '#FFF']} style={{height:8}} ></LinearGradient>
2.不使用插件:
<View style={{height:1,backgroundColor:'#e9e8e9'}} ></View>
<View style={{height:1,backgroundColor:'#e4e2e4'}} ></View>
<View style={{height:1,backgroundColor:'#efeeef'}} ></View>
<View style={{height:1,backgroundColor:'#f5f5f5'}} ></View>
<View style={{height:1,backgroundColor:'#fafafa'}} ></View>
<View style={{height:1,backgroundColor:'#fdfdfd'}} ></View>
<View style={{height:1,backgroundColor:'#fefefe'}} ></View>
<View style={{height:1,backgroundColor:'#fff'}} ></View>
是的,您可以使用以下代码制作自己视图的阴影:
<View style={{borderTopColor:'#ebebeb',borderTopWidth:1,borderBottomWidth:5,borderRightWidth:2,borderLeftWidth:2,borderColor:'#bcbaba',}}>
</View>
这个可以帮助我,请根据您的需求使用它。