react-native - 你如何使 react-native react-navigation 标签栏透明

标签 react-native react-navigation

有没有办法让标签栏透明?我尝试了以下方法,但它只显示了白色背景。我需要实现自己的 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,
        },
      }}>
这是输出屏幕截图。
Before set "elevation: 0", it was looking like this
After set "elevation: 0", it's looking perfect

关于react-native - 你如何使 react-native react-navigation 标签栏透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49988486/

相关文章:

reactjs - navigation.goback() 缺少数据

javascript - 带有反应导航的 React Native 中的侧边栏菜单

javascript - React Navigation 5,将屏幕移动到不同的导航器

javascript - 使用 Realm React Native 查找 Realm 文件的路径以与 Realm 浏览器一起使用

ios - React native 方向不起作用 ||锁定IOS

swift - 如何使用 react-native 组件创建一个 swift 项目?

reactjs - 使用 redux 响应 Native 导航 v3

react-native - Expo SDK 36, "componentWillReceiveProps has been renamed, and is not recommended for use"错误的通用解决方案

javascript - react native : Serving URI from localhost not rendering the image

javascript - React Native 节标题