简体   繁体   中英

react-native how to set-up PickerItems like color of text, fontSize etc,

I have Picker from 'react-native'. Picker.Item there are :"Monday, Tuesday, Wednesday etc". And I want to set up text properties. Like fontSize:20, color:"red" etc.

In Picker component we can use style. But there I can't change properties of text. Also I try to use ItemStyle={{color:"red"}}. But nothing change

<Picker
            style={{ flex: 1 }}
            selectedValue={this.props.shift}
            onValueChange={value => this.props.employeeUpdate({ prop: 
'shift', value })}
          >
            <Picker.Item label="Monday" value="Monday" />
            <Picker.Item label="Thuesday" value="Thuesday" />
            <Picker.Item label="Wednesdady" value="Wednesdady" />
            <Picker.Item label="Thursday" value="Thursday" />
            <Picker.Item label="Friday" value="Friday" />
            <Picker.Item label="Saturday" value="Saturday" />
            <Picker.Item label="Sunday" value="Sunday" />
          </Picker>

As said by the docs, itemStyle works only on iOS and has to be used on the global Picker component like: <Picker itemStyle={styles.pickerItemStyle} .

I'm pretty sure using the classic react-native Picker you can only change the color of an item using the prop color . These are the only props usable from Picker.item as said by the react-native docs: https://facebook.github.io/react-native/docs/picker-item

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM