Hus*_*aik 12 javascript react-native
我在我的TextInput中想要改变placeHolder字体的大小,我试过这样:
<TextInput
style={styles.email}
value={this.state.email}
placeholder="Email"
placeholderTextColor="red"
//placeholderTextSize = 20px
onChange={this.handleEmailChange.bind(this)}
onBlur={this.onBlur.bind(this)}/>
Run Code Online (Sandbox Code Playgroud)
当我写这样的颜色对我有用但尺寸不起作用,任何人都可以给我建议如何改变占位符文字的大小,任何帮助非常感谢
Big*_*n86 16
我不确定你是否只能指定placeholderText的大小.但是您可以从TextInput更改输入文本的fontSize:
var styles = StyleSheet.create({
email: {
fontSize: 12, <-- Textsize of Input-Text and Placeholder-Text
},
})
Run Code Online (Sandbox Code Playgroud)
也许你的解决方案没有px工作?!但我不这么认为.如果你想拥有一个与InputText不同的PlaceholderText,那么你可以访问onChangeText-TextInput的方法,并在你在Textfield中键入内容后立即更改fontSize.
小智 6
TextInput 组件可以这样创建。
<TextInput
value={value}
style={value ? styles.input : styles.placeholder}
placeholderTextColor="white"
{...props}
/>
Run Code Online (Sandbox Code Playgroud)
Note: You can't directly change the size of placeholder's text
上述解决方案有效,因为您赋予普通 textInput 的大小将直接应用于占位符
这里的技巧是我们有条件地检查用户是否输入了某些内容
输入时值将为 true,因此我们将应用输入样式,否则占位符样式通知样式将应用于 textInput 而不是占位符
| 归档时间: |
|
| 查看次数: |
10248 次 |
| 最近记录: |