更改按钮颜色ui小猫反应原生

问题描述 投票:0回答:1

如何使用react native库更改按钮文本的颜色?

我已经用以下代码尝试过。

    // styles
    button:
    {
        marginTop: 15,
        marginLeft: lrMargin,
        marginRight: lrMargin,
        color: 'white'
    }

                    <Button 
                        style={styles.button} 
                        status='basic'
                        color="red"
                        textColor="red"
                    >

                        LOGIN

                    </Button>
react-native button styling react-native-ui-kitten
1个回答
0
投票

简单的答案是您无法做到的,因为对于Android和IOS,按钮的呈现方式有所不同,所以另一种方法是提出自己的按钮。像这样的东西

<TouchableOpacity style={{backgroundColor:'red',width:100,height:20,alignItems:'center'}} onPress={()=>{}}>
  <Text style={{color:'white'}}>Test</Text>
  </TouchableOpacity>

如果您将此作为共享组件,则可以在任何地方使用它,并根据需要对其进行样式设置。

© www.soinside.com 2019 - 2024. All rights reserved.