【问题标题】:Applying gradient to Text only in Expo react native仅在 Expo 中将渐变应用于文本反应原生
【发布时间】:2021-01-16 04:39:16
【问题描述】:

很奇怪,我没有在网络上找到一个非常简单的功能的解决方案。 我想在 expo react native 项目中的文本中添加渐变。它看起来像这样

我确实看到了一个库(react-native-text-gradient),它自 0.5x 版本以来没有更新。 expo 的线性渐变创建一个按钮并对其应用渐变。 任何解决方案都将不胜感激。

【问题讨论】:

标签: javascript react-native expo gradient linear-gradients


【解决方案1】:

使用Masked View

<MaskedView
 style={{ height: 24 }}
 maskElement={<Text style={s.text}>{children}</Text>}
>
  <LinearGradient
    colors={['cadetblue', '#fabada']}
    start={{ x: 1, y: 1 }}
    end={{ x: 0, y: 0.33 }}
    style={{ flex: 1 }}
  />
</MaskedView>

【讨论】:

    猜你喜欢
    • 2018-05-07
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多