为什么iOS不以文本输入控件为中心? 我包括渲染和样式表 代码:
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.input}
onChangeText={(text) => this.setState({text})}
underlineColorAndroid='rgba(0,0,0,0)'
value={this.state.text}
placeholder= 'username'
/>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#13493A'
}
input: {
height: 40,
width: 250,
borderRadius: 5,
backgroundColor: '#598176',
color: 'white',
marginTop: 30,
textAlign: 'center'
}
});
提前谢谢你, 的安东尼奥
答案 0 :(得分:2)
查看问题跟踪器,这似乎是iOS上React Native的一个错误:#11892因此,您的代码应该可以正常工作但不会。列出的解决方法是将alignSelf: 'center'
添加到TextInput的样式(see example)。