【发布时间】:2021-07-30 14:17:55
【问题描述】:
我在 React Native 中遇到问题,我想隐藏标签栏导航正下方的底部操作栏。
我想制作一个 Disney + App 克隆,这件事让我很受不了:
我不知道该怎么做。 这是我的 App.js 代码:
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Ionicons } from '@expo/vector-icons';
import HomeScreen from './screens/HomeScreen';
import SearchScreen from './screens/SearchScreen';
import DownloadScreen from './screens/DownloadScreen';
import ProfilScreen from './screens/ProfilScreen';
import { iconSize, prefix, activeTabColor, inactiveTabColor, tabBarBackgroundColor, appTheme } from './utils/Constants';
import { ImageBackground } from 'react-native';
import DisneyImageBackground from './assets/home-background.png';
const Tab = createBottomTabNavigator();
export default function App() {
const getTabColor = (focused) => {
return focused ? activeTabColor : inactiveTabColor;
}
const getScreenOptions = (route) => {
}
return (
<ImageBackground source={DisneyImageBackground} style={{ flex: 1 }} resizeMode="cover">
<NavigationContainer theme={appTheme}>
<Tab.Navigator
screenOptions={
({ route }) => ({
tabBarIcon: ({ focused }) => {
if (route.name === 'Home') {
return <Ionicons name={`${prefix}-home`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Search') {
return <Ionicons name={`${prefix}-search`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Download') {
return <Ionicons name={`${prefix}-download`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Profil') {
return <Ionicons name={`${prefix}-person`} color={getTabColor(focused)} size={iconSize} />
}
},
})
}
tabBarOptions={{
activeBackgroundColor: tabBarBackgroundColor,
inactiveBackgroundColor: tabBarBackgroundColor,
showLabel: false,
style: {
height: 55,
borderTopWidth: 0.2,
borderTopColor: '#2f313d'
}
}}>
<Tab.Screen name='Home' component={HomeScreen} />
<Tab.Screen name='Search' component={SearchScreen} />
<Tab.Screen name='Download' component={DownloadScreen} />
<Tab.Screen name='Profil' component={ProfilScreen} />
</Tab.Navigator>
</NavigationContainer>
</ImageBackground>
);
}
如果有人有解决方案,那将非常有帮助:) 谢谢
【问题讨论】:
-
我不确定我是否关注你。但是你想要的是去除底部的白色区域,对吧?它被称为安全区域,您可以阅读文档来处理它。 reactnavigation.org/docs/handling-safe-area
-
@MicFung 是的,就是这样。我想删除安全区域。感谢您的文档
-
首先避免使用 SafeArea。是的,您将获得 StatusBar 区域的上边距...使用 SafeArea,但它也会添加 marginBottom 以使 ActionBar 可见
标签: javascript android reactjs react-native react-navigation