如何更改占位符颜色反应本机rnpickerselect

问题描述 投票:0回答:4
尝试以下方式:

style = { { inputIOS: {color: Constants.colour.black}, inputAndroid: {color: Constants.colour.black}, placeholderColor: Constants.colour.grey_90, } }

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; }} />
    
react-native
4个回答
9
投票
接受的答案与最新版本(2020年10月8.0.1)不起作用。

需要设置 placeholder: { color: 'red', }

style

参数,请参阅
https://github.com/lawnstarter/reaect-native-native-picker-select/issues/100#issuecomment-622469759

5
投票

在我的情况下,我使用了:

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', }, }}


0
投票

在我的案子中,我使用了此事并为我工作

<RNPickerSelect
    style={pickerSelectStyles}
    placeholder={{ label: 'Select your Gender', value: null }}
  />
 const pickerSelectStyles = {
        inputIOS: {},
        placeholder: {
           color: '#000 
             },
        inputAndroid: {},
     };

0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.