[英]React Native bottom tab navigator
I have a question, connected with a bottom tab navigator in React Native.我有一个问题,与 React Native 中的底部选项卡导航器有关。
Let assume that I have 6 screens, and I want to show only 5 in a bottom tab navigator.假设我有 6 个屏幕,我只想在底部选项卡导航器中显示 5 个。
<Screen
name='Home'
component={Home}
options={{
tabBarIcon: ({ focused }) => getTabIcon({ focused, source: walletIcon }),
}}
/>
and like these, 4 other screens too.和这些一样,还有其他 4 个屏幕。
I also have another screen, which I don't want to show at Navigator, and it looks like this.我还有另一个屏幕,我不想在 Navigator 上显示,它看起来像这样。
<Screen
name='EasyCoins'
component={EasyCoin}
/>
I also have tried to give an option property to my specific screen like this.我也尝试像这样为我的特定屏幕提供选项属性。 But this does not work for me.
但这对我不起作用。
options={{
tabBarVisible: false,
}}
I am using我在用
"@react-navigation/bottom-tabs": "^5.11.9",
"@react-navigation/native": "^5.9.4",
Build the screen you don't want to show using the stack-navigator.使用堆栈导航器构建您不想显示的屏幕。 In this case it will not appear in the tab bar and you can go to that page with any redirect.
在这种情况下,它不会出现在标签栏中,您可以通过任何重定向 go 到该页面。
You can have a look here -> https://reactnavigation.org/docs/stack-navigator/你可以看看这里-> https://reactnavigation.org/docs/stack-navigator/
React Native: Bottom Tabs Navigator is simple tab bar on the bottom of the screen. React Native:底部标签导航器是屏幕底部的简单标签栏。 Please visit my article for details bottom tabs navigator full code example.
请访问我的文章以获取详细信息底部选项卡导航器完整代码示例。 You can switch between different screen or routes.
您可以在不同的屏幕或路线之间切换。
You can have a look here -> https://www.extendfeature.com/react-native-bottom-tabs-navigator/你可以看看这里-> https://www.extendfeature.com/react-native-bottom-tabs-navigator/
//Initialized Bottom Tab Navigator
const Tab = createBottomTabNavigator();
<Tab.Navigator initialRouteName="Home"
screenOptions={{
tabBarInactiveBackgroundColor: "#011f3b",
tabBarActiveBackgroundColor: "#032845",
tabBarInactiveTintColor: "#f8ca12",
tabBarActiveTintColor: "#ffffff",
tabBarIconStyle: { marginTop: 4},
tabBarLabelStyle: { fontSize: 13, color: '#f8ca12', paddingBottom: 3},
tabBarStyle: {height: 55, position: 'absolute', bottom: 0, left: 0, right: 0, zIndex: 4, borderTopWidth: 0},
style: { borderColor: '#011f3b' },
headerShown: false,
unmountOnBlur: true,
}}
>
<Tab.Screen name="Home" component={HomeScreen}
options={{
tabBarLabel: 'Home',
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="home" color={color} size={29} style={{ marginTop: 1}} />
),
}}
/>
<Tab.Screen name="Login" component={LoginScreen}
options={{
tabBarLabel: 'Login',
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="login" color={color} size={29} style={{ marginTop: 1}} />
),
}}
/>
<Tab.Screen name="Register" component={RegisterScreen}
options={{
tabBarLabel: 'Register',
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="person-add" color={color} size={29} style={{ marginTop: 1}} />
),
}}
/>
<Tab.Screen name="About" component={AboutScreen}
options={{
tabBarLabel: 'About',
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="menu-book" color={color} size={29} style={{ marginTop: 1}} />
),
}}
/>
<Tab.Screen name="Profile" component={ProfileScreen}
options={{
tabBarLabel: 'Profile',
tabBarIcon: ({ color, size }) => (
<MaterialIcons name="account-circle" color={color} size={29} style={{ marginTop: 1}} />
),
}}
/>
</Tab.Navigator>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.