placeholder = {
label: placeholderText,
value: null,
color: Constants.colour.grey_90
};
update:
对于Android,您应该将占位符的颜色设置为类似的样式,希望我可以帮助某人:):
style={{
placeholder: {color: Constants.colour.grey_50},
inputIOS: { color: Constants.colour.black },
inputAndroid: { color: Constants.colour.black },
}}
我会建议您始终在包装主页中没有示例的github存储库中的问题板中查看。您可能在那里找到了解决方案。 在本期中,您将获得答案https://github.com/lawnstarter/reaeact-native-picker-select/issues/100
。 the是示例代码:
<RNPickerSelect
placeholder={{
label: 'Select a color...',
value: null,
}}
placeholderTextColor="red"
items={this.state.items}
onValueChange={(value) => {
this.setState({
favColor: value,
});
}}
onUpArrow={() => {
this.inputRefs.name.focus();
}}
onDownArrow={() => {
this.inputRefs.picker2.togglePicker();
}}
style={{ ...pickerSelectStyles }}
value={this.state.favColor}
ref={(el) => {
this.inputRefs.picker = el;
}}
/>
需要设置
placeholder: {
color: 'red',
}
style
https://github.com/lawnstarter/reaect-native-native-picker-select/issues/100#issuecomment-622469759
在我的情况下,我使用了:
const pickerStyle = {
inputIOS: {
color: 'white',
paddingHorizontal: 10,
backgroundColor: 'red',
borderRadius: 5,
},
placeholder: {
color: 'white',
},
inputAndroid: {
color: 'white',
paddingHorizontal: 10,
backgroundColor: 'red',
borderRadius: 5,
},
};
return (<RNPickerSelect style={pickerStyle} ... />)
这为我工作
style={{
placeholder: {
color: 'red',
},
}}
在我的案子中,我使用了此事并为我工作
<RNPickerSelect
style={pickerSelectStyles}
placeholder={{ label: 'Select your Gender', value: null }}
/>
const pickerSelectStyles = {
inputIOS: {},
placeholder: {
color: '#000
},
inputAndroid: {},
};