样式反应原生选择器 [英] Styling React Native Picker

查看:57
本文介绍了样式反应原生选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置React Native选取器中项目的文本颜色。到目前为止,我只在iOS上工作,但如果我能找到一个非常棒的跨平台解决方案。

I'm attempting to style the text color of the items in a React Native picker. I've only been working in iOS so far, but if I could find a cross-platform solution that'd be awesome.

我尝试过以下方法:

Picker上的样式颜色

Styling color on Picker

<Picker style={{color:'white'}} ...etc >

选择器项目的样式颜色

<Picker.Item style={{color:'#fff'}} label={'Toronto'} value={'Toronto'} />

我也看过一些添加颜色属性的例子,所以我试过这个

I've also seen some examples of adding a color property, so I tried this

<Picker.Item color='white' label={'Toronto'} value={'Toronto'} />

此处完全亏损。感谢您的任何见解!

At a total loss here. Thanks for any insight!

编辑:
这是一个解决方案 - 在Picker元素中使用itemStyle prop。我相信这只是iOS。

Here's a solution - use itemStyle prop in the Picker element. I believe this is iOS only.

<Picker itemStyle={{color:'white'}} >
      <Picker.Item color='white' label={'Toronto'} value={'Toronto'} />
      <Picker.Item  label={'Calgary'} value={'Calgary'} />
</Picker>


推荐答案

要更改颜色,需要使用此颜色:

To change the colour you need to use this:

<Item label="blue" color="blue" value="blue" />

这篇关于样式反应原生选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆