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 )

  

最新文章

  1. iOS NSURLConnection POST异步请求封装,支持转码GBK,HTTPS等
  2. 使linux服务器默认使用中文字符集zh_CN.UTF-8
  3. Android开发-修改AVD路径
  4. iOS--iOS7摄像头识别二维码功能
  5. poj 1275 Cashier Employment
  6. Asp.Net--主题/皮肤文件
  7. python学习第一天内容整理
  8. ActionMode 就记这么一点,不能更多了
  9. co源码解析
  10. macaca 测试web(2)
  11. ZOJ-2091-Mean of Subsequence (反证法的运用!!)
  12. C# 执行oracle sql 语句出现中文不兼容的问题
  13. Webdings字体和Wingdings字体对照表
  14. vue实现带规格商品的表格编辑
  15. 【Leetcode】404. Sum of Left Leaves
  16. 关于c语言中的program_invocation_short_name
  17. 2018-2019-1 20189206 《Linux内核原理与分析》第七周作业
  18. VM 虚拟机网络配置
  19. 大家所说的full-stack框架到底是指什么?
  20. Roslyn编译器-C#动态脚本实现方案

热门文章

  1. Gcc ------ gcc的使用简介与命令行参数说明
  2. ios一些问题
  3. CUDA从入门到精通 - Augusdi的专栏 - 博客频道 - CSDN.NET
  4. MYSQL主从不同步延迟原理分析及解决方案(摘自http://www.jb51.net/article/41545.htm)
  5. LinkedList详解
  6. python+Django框架运用(一)
  7. MyBatis学习笔记(三)——优化MyBatis配置文件中的配置
  8. Linux基础命令---dump
  9. QTQuick控件基础(3)视图
  10. Cortex-M3基础