在React Native中创建自定义的底部标签导航器

时间:2019-12-12 12:10:20

标签: javascript react-native react-navigation

我想在react native中创建时尚且自定义的底部标签导航的大家好,有人能在上面创建此提及内容有任何想法吗

enter image description here

5 个答案:

答案 0 :(得分:2)

在React Navigation V5中,有一个Tab.Navigator组件的道具,您可以传递整个自定义底部栏组件

<Tab.Navigator tabBar={(props) => <CustomTabBar/>}>
    <Tab.Screen .../>
</Tab.Navigator>

答案 1 :(得分:1)

看看这个很棒的框架,React-Native-Tab-View。

https://github.com/react-native-community/react-native-tab-view

只需使用tabBarPosition: bottom并根据需要呈现标签即可。

答案 2 :(得分:1)

很好的解释和使用反应导航

使用自定义标签栏的很好的例子

https://dev.to/hrastnik/lets-create-a-custom-animated-tab-bar-with-react-native-3496

答案 3 :(得分:1)

const customTabBarStyle = {
    activeTintColor: '#0091EA',
    inactiveTintColor: 'gray',
    style: {backgroundColor: 'white' },
}
return (
    <Tab.Navigator
    initialRouteName="Home"
    activeColor="#fff"
    tabBarOptions={customTabBarStyle}
    shifting="false">
    <Tab.Screen
    name="Home"
    options={{
        tabBarLabel: '',
        tabBarIcon: ({ color }) => (
            <Icon name="home" color={color} size={26} />
        )
    }}
    component={HomeScreen} />
    <Tab.Screen
    name="Workout"
    options={{
        tabBarLabel: '',
        tabBarIcon: ({ color }) => (
            <Icon name="fitness-center" color={color} size={26} />
        )
    }}
    component={WorkoutTabScreen} />
    <Tab.Screen
    name="Add"
    options={{
        tabBarLabel: '',
        tabBarIcon: ({ color }) => (
            <View
            style={{
                position: 'absolute',
                bottom: 0, // space from bottombar
                height: 68,
                width: 68,
                borderRadius: 68,
                justifyContent: 'center',
                alignItems: 'center',
            }}
            >
            <Icon name="add-circle-outline" color="grey" size={68}/>
            </View>
        )
    }}
    component={PayScreenComponent}/>
    <Tab.Screen
    name="Store"
    options={{
        tabBarLabel: '',
        tabBarIcon: ({ color }) => (
            <Icon name="store" color={color} size={26} />
        )
    }}
    component={StoreLandingScreen} />
    <Tab.Screen
    name="Profile"
    options={{
        tabBarLabel: '',
        tabBarIcon: ({ color }) => (
            <Icon name="perm-identity" color={color} size={26} />
        )
    }}
    component={ProfileScreen} />
    </Tab.Navigator>
);

output image

答案 4 :(得分:0)

   import {createBottomTabNavigator,} from 'react-navigation'

const ACTIVE_TAB_COLOR = '#60C3FF'
const INACTIVE_TAB_COLOR = '#aaa'



  const BottomStack = createBottomTabNavigator(
    {
      TAB_WALLET: {
        screen:Screen1,
        navigationOptions: {
          tabBarLabel: 'Screen1',
          tabBarIcon: ({ focused }) => <Icon name='iconname' focused={focused} color={focused ? ACTIVE_TAB_COLOR : INACTIVE_TAB_COLOR}/>
        }
      },
      TAB_SEND: {
        screen: Screen2,
        navigationOptions: {
          tabBarLabel: 'Screen2',
          tabBarIcon: ({ focused }) => <Icon name='search' focused={focused} color={focused ? ACTIVE_TAB_COLOR : INACTIVE_TAB_COLOR} />
        }
      },
      TAB_ACTIVITIES: {
        screen: Screen3,
        navigationOptions: {

          tabBarLabel: 'Screen3
          tabBarIcon: ({ focused }) => <Icon name='paper' focused={focused} color={focused ? ACTIVE_TAB_COLOR : INACTIVE_TAB_COLOR}/>
        }
      }
    },
    {
      tabBarPosition: 'bottom',
      swipeEnabled: false,
      animationEnabled: false,
      tabBarOptions: {
        activeTintColor: ACTIVE_TAB_COLOR,
        inactiveTintColor: INACTIVE_TAB_COLOR,
        showLabel: true,
        style: {
          borderTopWidth: 0,
          paddingTop: 3,
          paddingBottom: 4,
          height: 60,
          shadowColor: '#000',
          shadowOpacity: 0.1,
          shadowRadius: 20,
          shadowOffset: { width: 0, height: 0 }
        }
      }
    })