最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - react-native-datetimepicker Change Text Color - Stack Overflow

programmeradmin2浏览0评论

Issue

I need to change the color of the text displayed in the picker for react-native-datetimepicker as I have a very dark background and the text is extremely hard to see on it.

What I've Tried

I've tried passing in color: 'white' as a style to the DateTimePicker ponent and I've also tried passing in the itemStyle prop to the DateTimePicker ponent as that is how you change text styles on react-native's Picker ponent. Neither have worked.

Does anyone know how to change the text style in react-native-datetimepicker?

Example

Issue

I need to change the color of the text displayed in the picker for react-native-datetimepicker as I have a very dark background and the text is extremely hard to see on it.

What I've Tried

I've tried passing in color: 'white' as a style to the DateTimePicker ponent and I've also tried passing in the itemStyle prop to the DateTimePicker ponent as that is how you change text styles on react-native's Picker ponent. Neither have worked.

Does anyone know how to change the text style in react-native-datetimepicker?

Example

Share Improve this question asked Oct 28, 2019 at 20:03 bzlightbzlight 1,1605 gold badges21 silver badges47 bronze badges 4
  • Did you try textColor ? – Oleg Levin Commented Oct 28, 2019 at 20:18
  • @Oleg I tried adding a style prop textColor and I also tried adding textColor directly as a prop to the DateTimePicker ponent and neither worked. Where do you suggest I try adding in textColor? – bzlight Commented Oct 28, 2019 at 20:26
  • Have you tried isDarkModeEnabled=true? – Zaytri Commented Oct 28, 2019 at 20:28
  • 1 Look at github./henninghall/react-native-date-picker/issues/119 – Oleg Levin Commented Oct 28, 2019 at 20:29
Add a ment  | 

4 Answers 4

Reset to default 4

You have the property textColor available:

<DateTimePicker 
...
textColor="white" />

If you are using expo, you must go to node_modules/react-native-date-picker/style.js folder and use this:

dateText: {
    color: '#fff'
},

You have to pass in hex format. If you pass in #FFFFFF, the text color should change but there's an issue though. It only changes the color after a user interaction. The current date is always set to black. I don't think it can be modified though. https://developer.apple./documentation/uikit/uidatepicker, in this article it states that the UIDatePicker is not customizable.

try add themeVariant="light"

发布评论

评论列表(0)

  1. 暂无评论