React native 如何在TabNavigator的特定屏幕上隐藏标题
我有一个选项卡导航器:React native 如何在TabNavigator的特定屏幕上隐藏标题,react-native,react-navigation,React Native,React Navigation,我有一个选项卡导航器: const TabNav=createBottomTabNavigator({ 主页:{ 屏幕:主屏幕, 导航选项:{ 标题:"家",, }, }, 其他页面:{ 屏幕:其他页面, 导航选项:{ 标题:“NoHeader!”, }, }, 简介:{ 屏幕:ProfileScreen, 导航选项:{ 标题:“个人资料”, } }, }, { 选项卡选项:{ activeTintColor:'黑色', 风格:{ 背景颜色:“白色” }, } }); TabNav.naviga
const TabNav=createBottomTabNavigator({
主页:{
屏幕:主屏幕,
导航选项:{
标题:"家",,
},
},
其他页面:{
屏幕:其他页面,
导航选项:{
标题:“NoHeader!”,
},
},
简介:{
屏幕:ProfileScreen,
导航选项:{
标题:“个人资料”,
}
},
},
{
选项卡选项:{
activeTintColor:'黑色',
风格:{
背景颜色:“白色”
},
}
});
TabNav.navigationOptions={
标题:“标题标题”,
头灯:(
NavigationService.navigate('Rules')}
>
),
headerLeft:null,
}
导出默认TabNav;
我想在其他页面中隐藏标题,但在我的主页和个人资料页面中需要它
我试图在navigationOptions中设置header:null,但不起作用
有办法做到这一点吗?
或者在堆栈导航器headerMode中指定类似的内容:“screen”
编辑
我尝试在每个TabNavigator屏幕中添加导航选项,并在我的OtherPage中将其设置为null,如下所示:
const TabNav = createBottomTabNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
title: 'Home',
tabBarIcon: ({ tintColor, focused }) => (
<Icon
name={focused ? 'ios-list' : 'ios-list-outline'}
size={35}
style={{ color: tintColor }}
/>
),
headerRight: (
<TouchableOpacity
onPress={() => NavigationService.navigate('Rules')}
>
<Icon style={{ paddingRight: 10 }} name="ios-document" > </Icon>
</TouchableOpacity>
),
headerLeft: null,
},
},
OtherPage: {
screen: OtherPage,
navigationOptions: {
title: 'NoHeader!',
tabBarIcon: ({ tintColor, focused }) => (
<Icon
name={focused ? 'ios-flash' : 'ios-flash-outline'}
size={35}
style={{ color: tintColor }}
/>
),
header:null
},
},
Profile: {
screen: ProfileScreen,
navigationOptions: {
title: 'Profile',
tabBarIcon: ({ tintColor, focused }) => (
<Icon
name={focused ? 'ios-person' : 'ios-person-outline'}
size={35}
style={{ color: tintColor }}
/>
),
headerRight: (
<TouchableOpacity
onPress={() => NavigationService.navigate('Rules')}
>
<Icon style={{ paddingRight: 10 }} name="ios-document" > </Icon>
</TouchableOpacity>
),
headerLeft: null,
}
},
const TabNav=createBottomTabNavigator({
主页:{
屏幕:主屏幕,
导航选项:{
标题:"家",,
tabBarIcon:({tintColor,focused})=>(
),
头灯:(
NavigationService.navigate('Rules')}
>
),
headerLeft:null,
},
},
其他页面:{
屏幕:其他页面,
导航选项:{
标题:“NoHeader!”,
tabBarIcon:({tintColor,focused})=>(
),
标题:空
},
},
简介:{
屏幕:ProfileScreen,
导航选项:{
标题:“个人资料”,
tabBarIcon:({tintColor,focused})=>(
),
头灯:(
NavigationService.navigate('Rules')}
>
),
headerLeft:null,
}
},
但它也不起作用,当我这样做时,我在每个选项卡(甚至是我的OtherPage)上都有一个默认标题(没有标题,右侧没有按钮,…)。不是为TabNav定义导航选项,而是在每个TabNavigator屏幕中添加导航选项,然后在OtherPage中设置标题:null将起作用。例如
const TabNav=createBottomTabNavigator({
主页:{
屏幕:主屏幕,
导航选项:{
标题:"家",,
头灯:(<
触摸不透明度onPress={
()=>NavigationService.navigate('规则')
} >
<
图标样式={
{
填充右:10
}
}
name=“ios文档”>
可触摸不透明度>
),
headerLeft:null,
},
},
其他页面:{
屏幕:其他页面,
导航选项:{
标题:“NoHeader!”,
标题:空
},
},
简介:{
屏幕:ProfileScreen,
导航选项:{
标题:“简介”
头灯:(<
触摸不透明度onPress={
()=>NavigationService.navigate('规则')
} >
<
图标样式={
{
填充右:10
}
}
name=“ios文档”>
可触摸不透明度>
),
headerLeft:null,
}
},
}, {
选项卡选项:{
activeTintColor:'黑色',
风格:{
背景颜色:“白色”
},
}
})
这就成功了
const TabNavigator = createBottomTabNavigator({
Feed: FeedStack,
Profile: ProfileStack,
});
TabNavigator.navigationOptions = {
// Hide the header from AppNavigator stack
header: null,
};
不适用于我,现在我的3个选项卡中都有相同的默认标题,在主页和个人资料页面中,标题没有自定义,在我的其他页面标题中仍然显示。我的react navigation版本是2.0.2。您是否找到问题的答案?