如何在反应原生的开关内显示文本(是/否) [英] How to show text (YES/NO) inside a switch in react-native
本文介绍了如何在反应原生的开关内显示文本(是/否)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 react-native 的新手.在我的应用程序中,我正在使用一个开关并更改色调颜色来区分开和关,但我的实际要求是在开关内显示是"或否"文本,如下所示.
I am new to react-native. In my app, I'm using a switch and changing the tint color to differentiate ON and OFF, but my actual requirement is to show "YES" or "NO" text inside the switch like below.
这是我的代码:
<Switch
onValueChange={this.change.bind(this)}
style={{marginBottom:10,width:90,marginRight:6,marginLeft:6}}
value={true}
thumbTintColor="#0000ff"
tintColor="#ff0000"
/>
请给我解决这个问题的建议,非常感谢任何帮助.
Please give me suggestions to solve this issue, Any help much appreciated.
推荐答案
最后我把 On off inside switch ......
Finally I got the On off inside switch .......
安装
npm install --save react-native-switch
npm install --save react-native-switch
import { Switch } from 'react-native-switch';
<Switch
value={true}
onValueChange={(val) => console.log(val)}
disabled={false}
activeText={'On'}
inActiveText={'Off'}
backgroundActive={'green'}
backgroundInactive={'gray'}
circleActiveColor={'#30a566'}
circleInActiveColor={'#000000'}/>
参考这个链接...https://github.com/shahen94/react-native-switch
这篇关于如何在反应原生的开关内显示文本(是/否)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文