React Native自定义带返回按钮的标题栏组件
来源:互联网 发布:淘宝卖什么好呢 编辑:程序博客网 时间:2024/06/05 15:33
今天说的是左中右结构的标题栏,应用中最常见的就是左边一个返回按钮,中间一个标题。发现每次传的图片都显示不出来,就不发图了。
index.js代码部分:
import React, { Component,createClass } from 'react';import { View, Text, Image, TouchableOpacity, } from 'react-native';import StyleSheet from 'StyleSheet';export default React.createClass({ getDefaultProps(){ return { title:"标题", showBack:true,//是否显示左侧的返回 sideWidth:null, } }, backBtnFunc(){ this.props.backFunc ? this.props.backFunc.call(null) : this.props.navigator.pop(); }, render(){ return ( <View> <View style={styles.header}> <TouchableOpacity hitSlop={{top:10,left:10,right:10,bottom:10}} style={[styles.width50, this.props.sideWidth]} onPress={this.props.showBack ? this.backBtnFunc : undefined}> {this.props.showBack? <Image style={styles.backImg} source={asset(require("./back_btn.png"))} /> :null} </TouchableOpacity> <Text style={[styles.whiteColor,styles.textCenter,styles.headerText]} >{this.props.title.length>10?(this.props.title.substr(0,10)+"..."):this.props.title}</Text> <View style={[styles.width50, this.props.sideWidth]}> {this.props.children} </View> </View> </View> ) }})const styles = StyleSheet.create({ header:{ backgroundColor:"#4a9df8", height :45, flexDirection:"row", alignItems:"center" }, width50:{ width:$w_50 }, backImg:{ width:12, height:22, marginLeft:15 }, headerText:{ fontSize:18, flex:1 }, whiteColor:{ color:"#ffffff" }, textCenter:{ textAlign:"center" },});使用方法:
导入组件
import Header from "../../component/Header/index";使用组件
<Header {..._this.props} title="二维码管理" backFunc ={_this._backClick.bind(_this)} />
1 0
- React Native自定义带返回按钮的标题栏组件
- React Native自定义标题栏组件
- android带返回按钮的自定义标题栏
- android带返回按钮的自定义标题栏
- android带返回按钮的自定义标题栏布局文件详解
- React native自定义组件之Button按钮
- react -native 自定义按钮
- 【Android UI】自定义带按钮的标题栏
- 【Android UI】自定义带按钮的标题栏
- 【Android UI】自定义带按钮的标题栏
- 【Android UI】自定义带按钮的标题栏
- react-native 自定义组件
- Android React Native自定义组件的流程
- Android自定义带按钮标题栏
- react-native 自定义倒计时按钮
- React Native自定义BadgeView组件
- React-Native引用自定义组件
- react native 自定义基础组件
- Windows下Nginx的安装与配置
- integer对应的是resultType,不是resultMap
- HDU1262:寻找素数对(简单数论)
- 51Nod - 1116 枚举 + 模拟
- 关于android某些手机java.lang.UnsatisfiedLinkError: No implementation found for ......的问题
- React Native自定义带返回按钮的标题栏组件
- 基于jsonp技术的单点登入案例分享二
- 【C语言函数库】C语言中的string.h库常用函数
- JavaScript常用脚本集锦6
- Android 6.0新特性
- Signals & Slots
- Data Partitioning Guidance
- C 练习实例13 - 水仙花数
- 3.1 读入一个参数