2017-04-05 144 views
1

爲什麼iOS不使文本輸入控件居中? 我包括渲染和樣式表 代碼:TextInput對齊不居中iOS React-Native

left android, right 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' 
    } 
}); 

謝謝你在前進, 的安東尼奧

回答

2

找上了問題跟蹤,這似乎是在陣營上本地錯誤iOS:#11892所以你的代碼應該可以工作,但不能。列出的解決方法是將alignSelf: 'center'添加到TextInput的樣式(see example)。