首页 > 解决方案 > SVG 中的线性渐变、滤镜、蒙版、剪辑路径未在 iOS 中显示

问题描述

背景

在我的第一个 Ionic4 PWA 中,我有一些复杂的渐变需求(感谢一位才华横溢的设计师,他也是 PWA 的新手)。

fill:url(#the-gradient);许多 SVG 自定义图标通过我们的 .scss 文件调用许多不同的线性渐变。其中一些图标有 9 种状态(灰色、7 种颜色、彩虹)

此外,这些渐变在停靠点中使用 CSS 变量来进一步自定义基于主题的渐变。这些渐变当前存储在 index.html 中,以便所有图标都可以访问它们。

<svg aria-hidden="true" focusable="false" style="width:0;height:0;position:absolute;">
    <defs>
      <linearGradient id="default-icon-graydient" x1="0" x2="0" ,="" y1="1" y2="0">
        <stop offset="0%" stop-color="var(--gratiu-dark-grey)"/>
        <stop offset="100%" stop-color="var(--gratiu-ml-grey)"/>
      </linearGradient>
      <linearGradient id="select-icon-gradient" x1="0" x2="0" ,="" y1="1" y2="0">
        <stop offset="0%" stop-color="var(--gratiu-current-color)"/>
        <stop offset="50%" stop-color="var(--gratiu-current-color)"/>
        <stop offset="100%" stop-color="var(--gratiu-next-color)"/>
      </linearGradient>
<!--and many, many more...-->
    </defs>
</svg>

该系统在 android 和桌面上完美运行 - 但是在 iOS 上,无论是 safari 还是 chrome,图标都不会出现。

我尝试过的事情:

我觉得我目前的选择是:

显然,单个 PNG 比一个大的填充 SVG 更轻……但 SVG 的好处是它会加载一次并完成它。

对于问题:

标签: iosangularionic-frameworksvgionic4

解决方案


推荐阅读