首页 > 解决方案 > 在 react-native 中覆盖按钮背景颜色

问题描述

我是 react-native 的新手,我想知道是否有一种简单的方法可以覆盖按钮中的 backgroundColor。我确实尝试了很多方法,但没有运气。基本上我试图用我的自定义颜色默认替换蓝色背景。

有什么好的建议吗?

标签: cssreact-nativeuser-interfacebuttonmobile

解决方案


请浏览Button in react native 的文档,

您可以轻松地为 Button 的 color 属性提供所需的颜色,如下所示:

<Button
        title="Press me"
        color="black" // Color of your choice
        onPress={() => Alert.alert('Button with adjusted color pressed')}>

推荐阅读