如何在react native中更改警报按钮的颜色?



我开始了我的移动应用程序之旅,并试图找出为什么我的代码不改变警告按钮的颜色。导入Alert对象并使用其道具。我这次是在Android上测试的。

<Button
title="Button"
color="#ffab1a"
onPress={() =>
Alert.alert("My Alert", "My message", [
{ text: "Yes", style: { color: "red", backgroundColor: "green" } },
{ text: "No", style: { color: "red", backgroundColor: "blue" } },
])
}
/>

你不能自定义react native提供的默认警报,因为他们在内部使用android和ios设备的本地警报。

对于你的需求,你必须使用use React Native Modalbox,或者React Native Modal——它们都提供了一个高度可定制的模态组件。

最新更新