关于<TabNavigator>的item的一些用法 例如传递navigation
来源:互联网 发布:eia数据公布时间 编辑:程序博客网 时间:2024/05/22 15:01
_renderTab(Component,selectedTab,title, renderIcon,selectedIcon,position) {
return (
<TabNavigator.Item
//设置选中的位置
selected={this.state.selectedTab=== selectedTab}
//标题
title={title}
//标题样式
titleStyle={styles.tabText}
//选中时标题文字样式
selectedTitleStyle={styles.selectedTabText}
//提示消息文字
//badgeText = '122' 默认颜色蓝色
自定义颜色 红色 position是当前信息指数
renderBadge={()=>position?<View style={styles.badgeView}><Text style={styles.badgeText}>{position}</Text></View>:null}
//图标
renderIcon={()=> <Imagestyle={styles.icon}source={renderIcon}/>}
//选中时图标
renderSelectedIcon={()=> <Imagestyle={[styles.selectedIcon]}source={selectedIcon}/>}
onPress={()=> this.setState({ selectedTab:selectedTab })}
>
//{...this.props}向Component里面传递所有的属性 包含naviagtion
<Component {...this.props}theme={this.state.theme}homeComponent={this}/>
</TabNavigator.Item>
)
}
调用实例
{this._renderTab(RiskHiddenDanger,'首页', '首页', require('../../res/images/ic_one.png'),require('../../res/images/ic_one_press.png'),123)}
const styles =StyleSheet.create({
container: {
flex:1
},
scrollViewSize : {
height:Dimensions.get("window").height-73,
width :Dimensions.get("window").width,
},
tabText: {
fontSize:10,
color:'black'
},
selectedTabText: {
fontSize:10,
color:'orange'
},
badgeText : {
textAlign:'center' ,
backgroundColor:'red' ,
color:'white' ,
borderRadius:13 ,
height:25 ,
width:25
},
icon: {
width:22,
height:22,
tintColor:'black'
},
selectedIcon: {
width:22,
height:22,
tintColor:'orange'
},
page0: {
flex:1,
backgroundColor:'red'
},
page1: {
flex:1,
backgroundColor:'blue'
},
page2: {
flex:1,
backgroundColor:'yellow'
},
page3: {
flex:1,
backgroundColor:'green'
}
});
阅读全文
0 0
- 关于<TabNavigator>的item的一些用法 例如传递navigation
- React Navigation--TabNavigator 详细的例子
- React Navigation--TabNavigator 详细的例子
- 关于navigation的一些小知识
- Selectable的Navigation用法
- 【转】关于React Navigation的一些使用技巧
- IE编程 关于item的用法
- Flex4 关于TabNavigator 内部控件的初始化延迟问题!
- React Native商城项目实战04 - 封装TabNavigator.Item的创建
- Unity关于Navigation的教程
- 一些有用的Item
- 关于ListView的Item的一些定制化需求
- 关于html参数传递的一些理解
- 关于数组的一些用法
- 关于system()的一些用法
- 一些 关于 控件的用法
- 关于CListCtrl的一些用法
- 关于const的一些用法
- 阿里&百度&腾讯&facebook&Microsoft&Google开源项目汇总
- MAC下使用Charles抓取genymotion安卓模拟器中的数据
- CDH5 安装
- Docker stop停止/remove删除所有容器
- [Leetcode] 485. Max Consecutive Ones 解题报告
- 关于<TabNavigator>的item的一些用法 例如传递navigation
- Chasm.Ventsim.Visual.Premium.v3.8.3.0.build.10.10.2014.x86.x64\
- grep 介绍
- RESTEasy配置以及注解
- 字典Dict 判断指定键值是否存在
- CentOS安装scp命令
- applicationContext.xml配置业务层时候,显示找不到数据层的某某DAO的bean
- 想自杀?没门!Facebook利用AI预测用户自杀倾向
- mongodb数据库在linux下定时进行备份与清除