未找到名为“airport.express”的系统映像

问题描述

我正在使用 SwiftUI SF Symbols,在 iOS 14 上一切正常,但在 iOS 13 上却没有,错误如下:

[SwiftUI] No system image named 'doc.badge.gearshape' was found
[SwiftUI] No system image named 'airport.express' was found
[SwiftUI] No system image named 'rectangle.badge.plus' was found

用法很简单:

Image(systemName: "doc.badge.gearshape")

如果这是因为图标仅在 iOS 14 上退出,那么解决此问题的正确方法是什么? 我必须使用:

if #available(iOS 14.0,*) {
        Image(systemName: "doc.badge.gearshape")
} else {
    Image("xxx")
}

解决方法

你说得对。这些是从 iOS 14.0 添加的符号。 New symbols from iOS 14.0

您必须使用 iOS 13.0 的替代图像,正如您在上面的代码段中提到的那样。