深色模式底部标签的SafeArea颜色无法更改

SafeArea color of bottom tab in dark mode cannot be changed

从昨天开始我就一直卡在这个问题上,找不到解决办法。

我一直在尝试调整 iPhone X 中 safeArea 的颜色,它在顶部和底部都运行良好,对于没有选项卡的屏幕也是如此,但是,在带有选项卡导航器的屏幕中,如屏幕截图所示,底部安全区域始终为白色。有谁知道如何解决这个问题?

另外,我想问一下,如果使用普通的 SafeAreaView 组件并删除 SafeAreaProvider 和 react-native-safe-area-context 包是否会更好,我只是尝试添加它来解决这个问题但是我首先使用的是 React Native Normal SafeAreaView 组件;

在 App 组件中:

import { SafeAreaProvider } from "react-native-safe-area-context";
          <SafeAreaProvider>
            <NavigationContainer>
              <CatNavigator />
            </NavigationContainer>
          </SafeAreaProvider>

在 CatNavigator 组件中:

const CatNavigator = () => {
  return (
    <Drawer.Navigator
      initialRouteName="Home"    >
      <Drawer.Screen
        name="Home"
        component={SettingsNavigator}
        options={{ title: "Inicio" }}
      />
    </Drawer.Navigator>

在设置选项卡导航器中:

const SettingsNavigator = () => {
  return (
    <Tab.Navigator
      screenOptions={({ route }) => ({
        tabBarIcon: ({ focused, color, size }) => {
          let iconName;
          const iconType = Platform.OS === "ios" ? "ios" : "md";
          if (route.name === "Home") {
            iconName = iconType + "-home";
          } else if (route.name === "Settings") {
            iconName = iconType + "-settings";
          }
          const tabColor = focused ? Colors.buttonBackColor : Colors.titleColor;
          return <Ionicons name={iconName} size={size} color={color} />;
        },
      })}
      tabBarOptions={{
        activeTintColor: Colors.activeTabColor,
        inactiveTintColor: Colors.inactiveTabColor,
        activeBackgroundColor: Colors.tabBackgroundColor,
        inactiveBackgroundColor: Colors.tabBackgroundColor,
        safeAreaInset: { bottom: "never", top: "never" },
      }}
    >
      <Tab.Screen
        name="Home"
        component={HomeNavigator}
        options={{ title: "Inicio" }}
      />
      <Tab.Screen
        name="Settings"
        component={SettingStackNavigator}
        options={{ title: "Ajustes" }}
      />
    </Tab.Navigator>

在设置导航器中:

const SettingStackNavigator = (props) => {
  return (
    <SettingStack.Navigator screenOptions={defaultNavOptions}>
      <SettingStack.Screen
        name="Settings"
        component={SettingScreen}
        options={settingsOptions}
      />
    </SettingStack.Navigator>
  );
};

最后在设置屏幕中:

import { SafeAreaView } from "react-native-safe-area-context";
    return (
      <SafeAreaView
        style={{
             flex: 1,
    backgroundColor: Colors.backgroundColor,
          justifyContent: "center",
          alignItems: "center",
        }}
      >
        {colorScheme === "dark" && <StatusBar barStyle="light-content" />}
       // Other components
      </SafeAreaView>

如果你想改变底部那个小家伙的颜色,你需要将样式选项添加到你的Tab.Navigator,就像这样

 tabBarOptions={{
    style: {
      backgroundColor: Colors.tabBackgroundColor,
    },
  }}