gpt4 book ai didi

react-native - 如何在 React Native 中为文本设置透明文本颜色

转载 作者:行者123 更新时间:2023-12-05 08:08:28 32 4
gpt4 key购买 nike

是否可以将 Text 的颜色设置为透明,让文本单独继承父 View 的背景颜色,而不是它自己的背景颜色!

<View style={{ backgroundColor: 'red' }}>
<Text style={{ color: 'transparent', backgroundColor: 'blue' }}>
Change text colour progressively
</Text>
</View>

当前行为

由于文本颜色是透明的,它继承了它自己的背景颜色(蓝色),所以没有文本是可见的。

预期行为

单独的文本需要继承父 View 的背景颜色(红色)。

我的最终目标是实现一个动画,其中文本颜色可以逐渐改变。我不确定网络或任何行为中的行为,只是好奇是否有可能实现这一目标。

定位动画:

enter image description here

谢谢。

最佳答案

您可以尝试实现以下代码:

<View style={{ backgroundColor: 'red' }}>
<View style={{ color: 'transparent' }}>
<Text style={{ backgroundColor: 'blue' }}> Change text colour progressively </Text>
</View>
</View>

关于react-native - 如何在 React Native 中为文本设置透明文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49584405/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com