2016-04-04 80 views
0

是否可以在React Native上設置輸入佔位符的樣式。這是一個輸入。風格輸入佔位符R

<TextInput style={styles.input} 
      onChangeText={(password) => this.setState({password})} 
      value={this.state.password} 
      placeholder='Password' 
      secureTextEntry={true}/> 

如何定義styles.input來編輯佔位符的文本顏色?

在CSS上,需要供應商前綴。

+2

目前只能將'placeholderTextColor'定義爲''的屬性。夠了嗎? – zvona

+0

就是夠了! –

回答

0

這是我有它,我同樣.js文件裏面:

var styles = StyleSheet.create({ 
    description: { 
     marginBottom: 20, 
     fontSize: 18, 
     textAlign: 'center', 
     color: '#656565' 
    } 
    image: { 
     width: 217, 
     height: 138 
    }, 
    input: { 
    // your style 
    } 
}); 
+0

看起來不錯,但問題要求設置佔位符屬性的樣式。 –

+0

「我將如何定義styles.input?」 < - 這不是問題嗎? – TooManyEduardos

+0

「是否可以在React Native上設置輸入佔位符的樣式。」我編輯這個問題以使其更清楚 –

1

的TextInput文檔有一個道具叫placeholderTextColor。要實現這個屬性的方法是通過以下方式:

<TextInput style={styles.input} 
     onChangeText={(password) => this.setState({password})} 
     value={this.state.password} 
     placeholder='Password' 
     placeholderTextColor'#COLORHERE' 
     secureTextEntry={true}/> 

只有實現它首先他們的反應本地的文檔時,短暫到文檔涵蓋了很多。