在主屏幕上反应本地底部导航

时间:2018-07-13 08:30:52

标签: javascript android react-native

我有2个屏幕。 第一个是登录屏幕(不带标题),其中有“ createStackNavigation” 第二个是主屏幕,我要在其中找到底部导航栏(2个选项卡),在这两个选项卡中的每个选项卡中都带有标题。

我做了底部导航,但是自定义标头根本不起作用...它只是基本标头。任何人都可以有一些基本的例子吗?还是可以帮助我进行教程?

我在app.js中的代码:

const RootStack = createStackNavigator(
{
 Home: {
  screen: Login,

 navigationOptions: ({ navigation }) => ({
    header: null,
 }),

},
 Main: MainScreen,

},
{
 initialRouteName: 'Home',
 headerMode: 'screen',

}
);

“主”屏幕中的代码:

export default createBottomTabNavigator(
{
  Domov: {
    screen: HomeScreen,

  },
  Dnevnik: Diary,
},
{
  navigationOptions: ({ navigation }) => ({
     tabBarIcon: ({ focused, tintColor }) => {
       const { routeName } = navigation.state;
       let iconName;
       if (routeName === 'Domov') {

       iconName='home';
       } else if (routeName === 'Dnevnik') {

         iconName='ios-calendar';
       } 


   return (
       <Icon name={iconName} style={{fontSize: 20, color: '#FFF'}} />
   );
 },

 }),
   tabBarPosition: 'bottom',
   tabBarOptions: {
   activeTintColor: 'white',
   showLabel: false,
   inactiveTintColor: '#4C2601',
   style: {
     backgroundColor: '#033D51',
   },
 },

});

谢谢

1 个答案:

答案 0 :(得分:0)

在主屏幕的header: null中添加navigationOptions。您将可以添加自定义标头。

相关问题