为什么 Xcode 中的 SF Symbols 中的符号在 renderMode (.original) 中保持黑色

问题描述

Пример

SF Symbols Pro:16.0d18e1 Xcode: 11.6(11E708)

struct ContentView: View {
    var body: some View {
        Image(systemName: "cloud.sun.fill")
            .renderingMode(.original)
    }
}

enter image description here

如何使符号具有彩色外观?

解决方法

尽管您的字体版本足够新,可以支持多色 SF 符号,但您的 Xcode 版本却不是。这将需要 Xcode 12+ 版本和 iOS 14 模拟器。

在 Xcode 12.4/iOS 14.4 上运行的相同代码(带有大小和背景以使其更清晰):

struct ContentView: View {
    var body: some View {
        Image(systemName: "cloud.sun.fill")
            .renderingMode(.original)
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: 100,height: 100)
            .background(Color.blue)
    }

enter image description here