简体   繁体   English

SwiftUI - SF符号不渲染

[英]SwiftUI - SF Symbols Do Not Render

I'm trying to show a "plus" or "plus.app" sign via the SF Symbols in my code, but the preview to the right shows nothing. 我试图通过我的代码中的SF符号显示“加号”或“plus.app”符号,但右侧预览没有显示任何内容。

Other symbols do work like "plus.circle", is there a reason why the other symbols aren't working? 其他符号的工作方式类似于“plus.circle”,是否有其他符号不起作用的原因?

Here is my view. 这是我的看法。

var body: some View {
    NavigationView {
        List(items) { item in
            Text(item.description)
        }
        .navigationBarTitle(Text("Grocery Items"))
        .navigationBarItems(leading:
            PresentationButton(
                Image(systemName: "plus")
                    .imageScale(.large)
                    .padding(),
                destination: ItemDetailView(item: items[0])
            )
        )
    }
}

I expect the output to show the "plus.app" or "plus" symbol, but it shows nothing when I use those symbols. 我希望输出显示“plus.app”或“plus”符号,但是当我使用这些符号时它没有显示任何内容。

I had the same problem with the default preview device, as well as iPhone XS simulator. 我遇到了与默认预览设备以及iPhone XS模拟器相同的问题。

Changing the preview device to "iPhone XR" solved the issue for me. 将预览设备更改为“iPhone XR”为我解决了这个问题。 It's probably a bug and will be fixed in the next releases. 这可能是一个错误,将在下一个版本中修复。

You can change the preview device as below: 您可以更改预览设备,如下所示:

#if DEBUG
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
          .previewDevice(PreviewDevice(rawValue: "iPhone XR"))
    }
}
#endif

Update: 更新:

I tried the same with Xcode 11 beta 3 and it seems this issue was fixed. 我尝试使用Xcode 11 beta 3 ,但似乎这个问题已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM