如何使用react native库更改按钮文本的颜色?
我已经用以下代码尝试过。
// styles
button:
{
marginTop: 15,
marginLeft: lrMargin,
marginRight: lrMargin,
color: 'white'
}
<Button
style={styles.button}
status='basic'
color="red"
textColor="red"
>
LOGIN
</Button>
简单的答案是您无法做到的,因为对于Android和IOS,按钮的呈现方式有所不同,所以另一种方法是提出自己的按钮。像这样的东西
<TouchableOpacity style={{backgroundColor:'red',width:100,height:20,alignItems:'center'}} onPress={()=>{}}>
<Text style={{color:'white'}}>Test</Text>
</TouchableOpacity>
如果您将此作为共享组件,则可以在任何地方使用它,并根据需要对其进行样式设置。