React Native 的组件之底部导航栏 TabBarIOS(一)
import React,{Component}from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TabBarIOS,
} from 'react-native';
import History from './History'
class TabBarIOSDemo extends Component {
  constructor(props){
    super(props);
    this.state={
      selectedTab: '发现',
       notifCount: 0,
       presses: 0,
    };
  }
  //进行渲染页面内容
  _renderContent(color: string, pageText: string, num: number) {
    return (
      <View style={[styles.tabContent, {backgroundColor: color}]}>
        <Text style={styles.tabText}>{pageText}</Text>
      </View>
    );
  }
  render() {
    return (
      <View style={{flex:1}}>
        <TabBarIOS
        style={{flex:1,alignItems:"flex-end"}}
        tintColor="green"/*被选中状态颜色图片和文字*/
        barTintColor="#000">
        <TabBarIOS.Item
          title="主页"
          icon={require('./img/1.png')}
          selected={this.state.selectedTab === '主页'}
          onPress={() => {
            this.setState({
              selectedTab: '主页',
            });
          }}
          >
          {this._renderContent('#414A8C', 'one')}
        </TabBarIOS.Item>
        <TabBarIOS.Item
          title="发现"
          icon={require('./img/2.png')}
          selected={this.state.selectedTab === '发现'}
          onPress={() => {
            this.setState({
              selectedTab: '发现',
              notifCount: this.state.notifCount + 1,
            });
          }}
          >
          {this._renderContent('#cccccc', '发现', this.state.notifCount)}
        </TabBarIOS.Item>
        <TabBarIOS.Item
          title="我的"
          icon={require('./img/3.png')}
          selected={this.state.selectedTab === '我的'}
          badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
          onPress={() => {
            this.setState({
              selectedTab: '我的',
              notifCount: this.state.notifCount + 1,
            });
          }}
          >
          {this._renderContent('#783E33', '历史记录', this.state.notifCount)}
        </TabBarIOS.Item>
        <TabBarIOS.Item
           title="信息"
           icon={require('./img/4.png')}
           selected={this.state.selectedTab === '下载'}
            onPress={() => {
            this.setState({
              selectedTab: '下载',
              presses: this.state.presses + 1
            });
          }}>
           {this._renderContent('#21551C', '下载页面', this.state.presses)}
        </TabBarIOS.Item>
      </TabBarIOS>
      </View>
    );
  }
}
const styles = StyleSheet.create({
  tabContent: {
    flex: 1,
    alignItems: 'center',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    marginTop: 20,
  },
  tabText: {
    color: 'white',
    margin: 50,
  },
});
AppRegistry.registerComponent('Allen', () => TabBarIOSDemo )
React Native 的组件之底部导航栏 TabBarIOS(一)的更多相关文章
- React Native(四)——顶部以及底部导航栏实现方式
		效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ... 
- Flutter——BottomNavigationBar组件(底部导航栏组件)
		BottomNavigationBar常用的属性: 属性名 说明 items List<BottomNavigationBarItem> 底部导航条按钮集合 iconSize icon c ... 
- React native中DrawerNavigator,StackNavigator,TabNavigator导航栏使用
		import React from 'react'; import { View, Text,Button } from 'react-native'; import { DrawerNavigato ... 
- 微信小程序自定义底部导航栏组件+跳转
		微信小程序本来封装有底部导航栏,但对于想自定义样式和方法的开发者来说,这并不是很好. 参考链接:https://github.com/ljybill/miniprogram-utils/tree/ma ... 
- Vue 如何实现一个底部导航栏组件
		参考网址: https://www.jianshu.com/p/088936b7b1bd/ Vue 如何实现一个底部导航栏组件 可以看到父组件是知道我点击了底部TabBar的哪个item的. 实现 实 ... 
- 【Flutter学习】基本组件之BottomNavigationBar底部导航栏
		一,概述 BottomNavigationBar即是底部导航栏控件,显示在页面底部的设计控件,用于在试图切换,底部导航栏包含多个标签.图标或者两者搭配的形式,简而言之提供了顶级视图之间的快速导航. 二 ... 
- React-native 底部导航栏(二)
		1.组件安装:npm install react-native-router-flux --save 2.定义菜单图片和文字: import React, { Component } from 're ... 
- Android应用底部导航栏(选项卡)实例
		现在很多android的应用都采用底部导航栏的功能,这样可以使得用户在使用过程中随意切换不同的页面,现在我采用TabHost组件来自定义一个底部的导航栏的功能. 我们先看下该demo实例的框架图: 其 ... 
- React Native的组件ListView
		React Native的组件ListView类似于iOS中的UITableView和UICollectionView,也就是说React Native的组件ListView既可以实现UITableV ... 
随机推荐
- break  continue练习
			break :跳出 1.当break单独存在时,下面不要定义其他语句,因为执行不到. 2.如果出现了循环嵌套,break响应跳出指定的循环,可以通过标号来完成 例如: continue:要么是swit ... 
- Python安装sqlite3
			今天使用PYthon时,发现错误 ImportError: No module named sqlite 这是因为缺少 SQLITE3的缘故. 下面分享一下解决此问题的方法步骤: 1. 查看是Pyth ... 
- POJ:3083 Children of the Candy Corn(bfs+dfs)
			http://poj.org/problem?id=3083 Description The cornfield maze is a popular Halloween treat. Visitors ... 
- pandas使用drop_duplicates去除DataFrame重复项
			DataFrame中存在重复的行或者几行中某几列的值重复,这时候需要去掉重复行,示例如下: data.drop_duplicates(subset=['A','B'],keep='first',inp ... 
- jmeter 线程组之间的参数传递(加密接口测试三)
			场景测试中,一次登录后做多个接口的操作,然后登录后的uid需要关联传递给其他接口发送请求的时候使用. 1.在登录接口响应信息中提取uid字段值 1>login请求 -->添加 --> ... 
- python  安装 Scrapy 模块
			环境的安装总是让人多愁善感,爱恨交叉... 本人安装环境:win7 64 + python2.7 先来几个网站 https://doc.scrapy.org/en/latest/intro/insta ... 
- unp第七章补充之socket tcp 产生 rst响应的情况
			socket tcp 产生 rst响应的情况(属于硬错误) 1. syn发送到服务器主机,但是目的端口并未运行.则产生一个ECONRFUSED错误.客户端立即返回.比如telnet 192.1 ... 
- LeetCode7.反转整数
			给定一个 32 位有符号整数,将整数中的数字进行反转. 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: 21 注意: 假 ... 
- MyBatis学习笔记(五)——实现关联表查询
			转自孤傲苍狼的博客:http://www.cnblogs.com/xdp-gacl/p/4264440.html 一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创 ... 
- Linux服务器---网络配置
			禁止ping 有些时候为了保护主机,会禁止其他机器对主机进行ping操作.Ping命令用的是ICMP协议,只要禁用ICMP协议,那么ping方法就无法检测这台主机.关于ICMP协议的配置文件是“/pr ... 
