2016-04-04 76 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}/> 

只有实现它首先他们的反应本地的文档时,短暂到文档涵盖了很多。