1. import React,{Component}from 'react';
  2. import {
  3. AppRegistry,
  4.  
  5. StyleSheet,
  6. Text,
  7. View,
  8. TabBarIOS,
  9. } from 'react-native';
  10. import History from './History'
  11. class TabBarIOSDemo extends Component {
  12. constructor(props){
  13. super(props);
  14. this.state={
  15. selectedTab: '发现',
  16. notifCount: 0,
  17. presses: 0,
  18. };
  19. }
  20. //进行渲染页面内容
  21. _renderContent(color: string, pageText: string, num: number) {
  22. return (
  23. <View style={[styles.tabContent, {backgroundColor: color}]}>
  24. <Text style={styles.tabText}>{pageText}</Text>
  25.  
  26. </View>
  27. );
  28. }
  29. render() {
  30. return (
  31. <View style={{flex:1}}>
  32.  
  33. <TabBarIOS
  34. style={{flex:1,alignItems:"flex-end"}}
  35. tintColor="green"/*被选中状态颜色图片和文字*/
  36. barTintColor="#000">
  37. <TabBarIOS.Item
  38. title="主页"
  39. icon={require('./img/1.png')}
  40. selected={this.state.selectedTab === '主页'}
  41. onPress={() => {
  42. this.setState({
  43. selectedTab: '主页',
  44. });
  45. }}
  46. >
  47. {this._renderContent('#414A8C', 'one')}
  48. </TabBarIOS.Item>
  49. <TabBarIOS.Item
  50. title="发现"
  51. icon={require('./img/2.png')}
  52. selected={this.state.selectedTab === '发现'}
  53.  
  54. onPress={() => {
  55. this.setState({
  56. selectedTab: '发现',
  57. notifCount: this.state.notifCount + 1,
  58. });
  59. }}
  60. >
  61. {this._renderContent('#cccccc', '发现', this.state.notifCount)}
  62. </TabBarIOS.Item>
  63. <TabBarIOS.Item
  64. title="我的"
  65. icon={require('./img/3.png')}
  66. selected={this.state.selectedTab === '我的'}
  67. badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
  68. onPress={() => {
  69. this.setState({
  70. selectedTab: '我的',
  71. notifCount: this.state.notifCount + 1,
  72. });
  73. }}
  74. >
  75. {this._renderContent('#783E33', '历史记录', this.state.notifCount)}
  76. </TabBarIOS.Item>
  77. <TabBarIOS.Item
  78. title="信息"
  79. icon={require('./img/4.png')}
  80. selected={this.state.selectedTab === '下载'}
  81. onPress={() => {
  82. this.setState({
  83. selectedTab: '下载',
  84. presses: this.state.presses + 1
  85. });
  86. }}>
  87. {this._renderContent('#21551C', '下载页面', this.state.presses)}
  88. </TabBarIOS.Item>
  89.  
  90. </TabBarIOS>
  91. </View>
  92. );
  93. }
  94. }
  95. const styles = StyleSheet.create({
  96. tabContent: {
  97. flex: 1,
  98. alignItems: 'center',
  99. },
  100. welcome: {
  101. fontSize: 20,
  102. textAlign: 'center',
  103. marginTop: 20,
  104. },
  105. tabText: {
  106. color: 'white',
  107. margin: 50,
  108. },
  109. });
  110.  
  111. AppRegistry.registerComponent('Allen', () => TabBarIOSDemo )

  

React Native 的组件之底部导航栏 TabBarIOS(一)的更多相关文章

  1. React Native(四)——顶部以及底部导航栏实现方式

    效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...

  2. Flutter——BottomNavigationBar组件(底部导航栏组件)

    BottomNavigationBar常用的属性: 属性名 说明 items List<BottomNavigationBarItem> 底部导航条按钮集合 iconSize icon c ...

  3. React native中DrawerNavigator,StackNavigator,TabNavigator导航栏使用

    import React from 'react'; import { View, Text,Button } from 'react-native'; import { DrawerNavigato ...

  4. 微信小程序自定义底部导航栏组件+跳转

    微信小程序本来封装有底部导航栏,但对于想自定义样式和方法的开发者来说,这并不是很好. 参考链接:https://github.com/ljybill/miniprogram-utils/tree/ma ...

  5. Vue 如何实现一个底部导航栏组件

    参考网址: https://www.jianshu.com/p/088936b7b1bd/ Vue 如何实现一个底部导航栏组件 可以看到父组件是知道我点击了底部TabBar的哪个item的. 实现 实 ...

  6. 【Flutter学习】基本组件之BottomNavigationBar底部导航栏

    一,概述 BottomNavigationBar即是底部导航栏控件,显示在页面底部的设计控件,用于在试图切换,底部导航栏包含多个标签.图标或者两者搭配的形式,简而言之提供了顶级视图之间的快速导航. 二 ...

  7. React-native 底部导航栏(二)

    1.组件安装:npm install react-native-router-flux --save 2.定义菜单图片和文字: import React, { Component } from 're ...

  8. Android应用底部导航栏(选项卡)实例

    现在很多android的应用都采用底部导航栏的功能,这样可以使得用户在使用过程中随意切换不同的页面,现在我采用TabHost组件来自定义一个底部的导航栏的功能. 我们先看下该demo实例的框架图: 其 ...

  9. React Native的组件ListView

    React Native的组件ListView类似于iOS中的UITableView和UICollectionView,也就是说React Native的组件ListView既可以实现UITableV ...

随机推荐

  1. Kylin安装问题--/home/hadoop-2.5.1/contrib/capacity-scheduler/.jar (No such file or directory)

    WARNING: Failed to process JAR [jar:file:/home/hadoop-2.5.1/contrib/capacity-scheduler/.jar!/] for T ...

  2. Kylin构建cube时状态一直处于pending

    在安装好kylin之后我直接去访问web监控页面发现能够进去,也没有去看日志.然后在运行官方带的例子去bulid cube时去发现状态一直是pending而不是runing.这个时候才去查看日志: 2 ...

  3. rsync+inotify安装配置 实时同步文件

    安装 #安装inotify 工具 [root@localhost ~]# yum install inotify-tools -y 常用命令 [root@localhost ~]# inotifywa ...

  4. iOS UI基础-4.2应用程序管理 Xib文件使用

    Xib调整使用 1.新建xib文件 New File-->User Interface-->Empty 2.打开新建的xib文件,出现可视化窗口 (1)拖入一个UIView (不是UIVi ...

  5. arcgis中加载google在线地图

    打开arcmap——文件——arcgis online ——搜索china maps 选择china

  6. FRM-40212: Invalid value for field %s.

    Cause:        Caused by one of the following: 1.  The value is not of the proper data type. 字段类型不对 2 ...

  7. Hdu dp

    4856 这题说的是给了一个图 这个图有很多的隧道每个隧道是单向的 只能从一个入口进入从另一个入口出来 要求计算出走完这些隧道花的总时间 因为这个图是一个网格行的然后 先用bfs算出隧道的出口到每个隧 ...

  8. linux常用命令:killall 命令

    killall命令用进程的名字来杀死进程. 1.命令格式:    killall [ -egiqvw ] [ -signal ] [进程名称] 格式:killall -<signame> ...

  9. 借助IDE到处Runnable JAR 的步骤

    1. 选择项目,右键,export,选择Java目录下的Runnable JAR file , next 2. Lanch configuration 中选择启动类 3. Export destina ...

  10. Linux基础命令---swapoff

    swapoff 关闭交换分区,同时可以刷新交换分区的缓存.关闭交换分区后,使用free指令查看内存,swap数值会减少.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE. ...