【问题标题】:React Native: "tintColor" not working for Image on iOS 15React Native:“tintColor”不适用于 iOS 15 上的图像
【发布时间】:2021-11-15 16:44:53
【问题描述】:

我的应用中有一些这样的代码:

<Image
  style={{width: 50, height: 50, tintColor: 'yellow'}}
  source={fabicon}
/>

这在 Android 和 iOS tintColor 不适用于我在 iOS 15 上的任何图标。

我使用的是 React Native 版本 0.62.2。

谁能告诉我如何在 iOS 15(及更高版本)上将色调应用于图像?如果我不能,我是否为我想要图像的每种颜色制作单独的图像?我可以使用 SVG,但这也不是我的应用程序中每个场景的选项。

【问题讨论】:

  • 这听起来确实很奇怪。您应该在 react-native 的 github 上打开一个问题。同时,您将不得不寻找替代方案,可能会提前创建不同颜色的图像,使用您提到的图标或 SVG

标签: ios image react-native


【解决方案1】:

我在 React Native 的 repo 上提出了这个问题:

https://github.com/facebook/react-native/issues/32251

他们于 2021 年 10 月 2 日发布了新的 RN 版本 0.66.0。我已确认 tintColor 可在此新版本上工作并关闭此问题。

对于 RN 66 岁以下的任何人,如果对 Image tintColor 有此问题,您可以升级到 RN 66 以使 tintColor 工作。如果现在无法升级,您可以使用react-native-fast-image,直到可以升级为止。或者,您可以根据需要使用不同颜色的图像或 SVG 版本。如果您的着色图像主要是图标,您也可以使用react-native-vector-icons

【讨论】:

    猜你喜欢
    • 2017-06-08
    • 2019-01-31
    • 1970-01-01
    • 2023-03-02
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 2017-02-02
    • 2018-11-15
    相关资源
    最近更新 更多