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 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...
react 本身提供了克隆组件的方法,但是平时开发中可能很少使...
mobx 是一个简单可扩展的状态管理库,中文官网链接。小编在接...
我们在平常的开发中不可避免的会有很多列表渲染逻辑,在 pc ...