react native之TabBar底部导航(兼容Android和IOS)--react-native-tab-navigator

react native之TabBar底部导航(兼容Android和IOS)-- react-native-tab-navigator

1.下载依赖

npm install react-native-tab-navigator --save

具体如何使用查看node_modules找到该组件查看README和点开里面的js查看所可以设置的属性

```js
import TabNavigator from 'react-native-tab-navigator';
```

This is an example of how to use the component and some of the commonly used props that it supports:

```js
<TabNavigator>
  <TabNavigator.Item
    selected={this.state.selectedTab === 'home'}   //选中的状态
    title="Home"   //Tabbar的文字
    renderIcon={() => <Image source={...} />}  //TabBar的图标,注意要设置大小
    renderSelectedIcon={() => <Image source={...} />}  //TabBar选中时候的图标,注意要设置大小
    badgeText="1"   //右上角的字
    onPress={() => this.setState({ selectedTab: 'home' })}
    titleStyle={{color:"red”}}   //未选中状态文字的大小
    selectedTitleStyle={{color:"green”}}  //选中状态文字的大小
  >
    <HomeView/>
  </TabNavigator.Item>
  <TabNavigator.Item
    selected={this.state.selectedTab === 'profile'}   //选中的状态
    title="Profile"   //Tabbar的文字
    renderIcon={() => <Image source={...} />}  //TabBar的图标,注意要设置大小
    renderSelectedIcon={() => <Image source={...} />} //TabBar选中时候的图标,注意要设置大小
    renderBadge={() => <CustomBadgeView />}
    onPress={() => this.setState({ selectedTab: 'profile' })}
    titleStyle={{color:"red”}}   //未选中状态文字的大小
    selectedTitleStyle={{color:"green”}}  //选中状态文字的大小
  >
    <ProfileView/>
  </TabNavigator.Item>
</TabNavigator>
```

See TabNavigatorItem's supported props for more info.

### Hiding the Tab Bar

You can hide the tab bar by using styles. For example:
```js
let tabBarHeight = 0;
<TabNavigator
  tabBarStyle={{ height: tabBarHeight,overflow: 'hidden' }}
  sceneStyle={{ paddingBottom: tabBarHeight }}
/>
```

相关文章

一、前言 在组件方面react和Vue一样的,核心思想玩的就是组件...
前言: 前段时间学习完react后,刚好就接到公司一个react项目...
前言: 最近收到组长通知我们项目组后面新开的项目准备统一技...
react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...