【发布时间】:2018-11-24 10:00:00
【问题描述】:
我有一个标签导航器:
const TabNav = createBottomTabNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
title: 'Home',
},
},
OtherPage: {
screen: OtherPage,
navigationOptions: {
title: 'NoHeader!',
},
},
Profile: {
screen: ProfileScreen,
navigationOptions: {
title: 'Profile',
}
},
},
{
tabBarOptions: {
activeTintColor: 'black',
style: {
backgroundColor: 'white'
},
}
});
TabNav.navigationOptions = {
title: 'Header Title',
headerRight: (
<TouchableOpacity
onPress={() => NavigationService.navigate('Rules')}
>
<Icon style={{ paddingRight: 10 }} name="ios-document" > </Icon>
</TouchableOpacity>
),
headerLeft: null,
}
export default TabNav;
我想在 OtherPage 中隐藏页眉,但在我的主页和个人资料页中需要它。
我尝试在 navigationOptions 中设置 header:null,但它不起作用。
有没有办法做到这一点? 或者也许可以在堆栈导航器 headerMode:'screen' 中指定?
编辑
我尝试在每个 TabNavigator 屏幕中添加 navigationOtions,并在我的 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,
}
},
但它也不起作用,当我这样做时,我在每个选项卡(甚至是我的 OtherPage)上都有一个默认标题(没有标题,右侧没有按钮,...)。
【问题讨论】:
-
您找到问题的答案了吗?
标签: react-native react-navigation