动态控制文本输入框的显示与隐藏为后面实现仿微信朋友圈评论自动定位 做好准备
constructor(props) { es6的写法
super(props);this.state = {
TextInputShow:false, //根据TextInputShow的值来控制底部文本输入框的显示和隐藏
text:'', //文本输入框的内容
}
render( ){
return (
<View>
{this.state.TextInputShow?(
<TextInput
ref={TEXTINPUT_REF}
underlineColorAndroid='#27c08a'
autoFocus={true}
style={{width: Dimensions.get('window').width - 70, height: 50}}
onChangeText={(text) => this.setState({text})}
value={this.state.text}
/>):(<View></View>)
} )
<TouchableOpacity
style={[{height:34,backgroundColor:'#fafafa',marginTop:5}]}
onPress={()=>{
this.setState({TextInputShow:!TextInputShow});
}}
>
文本输入框的显示与隐藏
</TouchableOpacity>
</View>
}