有没有办法让标签栏透明?我尝试了以下方法,但它只显示了白色背景。我需要实现自己的 tabBarComponent 吗?如果是这样,是否有关于该类的任何文档以及我需要实现的接口(interface)?
const MainTabNavigator = TabNavigator(
{
MessageCenter: { screen: MessageCenterStack },
Camera: { screen: CameraStack },
},
{
tabBarPosition: 'bottom',
swipeEnabled: true,
animationEnabled: true,
tabBarOptions: {
style: {
backgroundColor: 'transparent',
},
}
}
);
最佳答案
position: 'absolute' 是一个解决方案,但你可能会注意到它在 android 端看起来并不完美,但在 android 端完美运行。
经过长时间的努力,我终于找到了解决方案。
海拔:0
在标签栏样式上设置此项将解决此问题。
例子 -
tabBarOptions={{
showIcon: true,
showLabel: true,
activeTintColor: COLORS.tabSelected,
inactiveTintColor: COLORS.tabNormal,
style: {
backgroundColor:'transparent',
borderTopWidth: 0,
position: 'absolute',
elevation: 0 // <-- this is the solution
},
labelStyle: {
fontSize: 12,
},
}}>
这是输出屏幕截图。关于react-native - 你如何使 react-native react-navigation 标签栏透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49988486/