简体   繁体   English

使用 React Native 在标签栏中显示图标

[英]Displaying icons in tab bar with React Native

I am new to react native and am trying to display icons within my tab menu.我是本地人的新手,正在尝试在我的选项卡菜单中显示图标。

I have tried using FontAwesome, FontAwesome5, react-native-vector-icons and Ionicons.我尝试过使用 FontAwesome、FontAwesome5、react-native-vector-icons 和 Ionicons。 None of these seems to be displaying any icons and I don't know why.这些似乎都没有显示任何图标,我不知道为什么。

标签栏

Here is my code.这是我的代码。

 const TabNavigator = createBottomTabNavigator({ Home: { screen: HomeScreen, defaultnavigationOptions: { tabBarIcon: ({ tintColor }) => ( <Icon name="home" color="#ccc"size={25} /> ) }, }, Events: { screen: EventScreen, defaultnavigationOptions: { tabBarIcon: ({ tintColor }) => ( <Icon name="home" color="#ccc"size={25} /> ) }, About: { screen: AboutScreen, defaultnavigationOptions: { tabBarIcon: ({ tintColor }) => ( <Icon name="home" color="#ccc"size={25} /> ) } }, { tabBarOptions: { showIcon: true, activeTintColor: '#D4AF37', inactiveTintColor: 'gray', style: { backgroundColor: 'white', }, labelStyle: { fontSize: 20, } } } );

Try this way试试这个方法

const MainNavigator = createBottomTabNavigator(
  {
    Home: {
      screen: HomeNavigation,
      navigationOptions: ({navigation}) => ({
        title:  'home',
        tabBarIcon: <Icon name="home" color="#ccc"size={25} />,
      }),

    },
 {
    initialRouteName: 'Home',
    lazy: false,
    tabBarOptions: {
        activeTintColor: '#d63921',
        labelPosition: 'below-icon'
      },
  },
);

feel free for doubts.有疑问请随意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当标签在 React Native 中处于活动状态或未处于活动状态时更改标签栏图标 - Change tab bar icons when a tab is active or not in React Native 反应本机导航选项卡栏 - react native navigation tab bar React Native Navigation-createBottomTabNavigator和隐藏选项卡栏 - React Native Navigation - createBottomTabNavigator and hiding Tab Bar React Native-导航器和标签栏集成 - React Native - Navigator and Tab Bar integration 如何在React Native中向标签栏添加新标签? - How to add a new tab to tab bar in react native? React Native - React Navigation Tab Bar - 自定义浮动操作按钮 - React Native - React Navigation Tab Bar - Custom floating action button React Native - 根据标签栏文本宽度更改指示器宽度(react-native-tab-view) - React Native - Changing the indicator width according to tab bar text width (react-native-tab-view) 如何在 React Native 中垂直居中标签栏中的标签 - How to vertically centre tabs inside tab bar in react native 如何在 React Native 中更改 Botton 标签栏背景颜色? - How to change Botton tab bar Background Color in React Native? React Native Navigation:有条件地渲染标签栏徽章不起作用? - React Native Navigation: Conditionally render tab bar badge not working?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM