简体   繁体   中英

Custom SF Symbol not rendering hierarchical shading

I have a custom SF Symbol that renders with hierarchical shading when viewed in the SF Symbols 3 app, but in iOS using SwiftUI it renders as monochrome.

Here is the symbol in the SF Symbols 3 app:

SF Symbols 3 应用程序中显示图层的自定义符号

Here is the symbol imported as a 3.0 template in the asset catalog:

资产目录中的符号

Here is the code to render it:

  Image("custom.figure.steps")
    .font(.largeTitle)
    .padding(.trailing)
    .symbolRenderingMode(.hierarchical)
    .foregroundColor(status.statusColor)

Here is how it renders in iOS simulator:

在 iOS 中呈现的自定义符号

How do I get the hierarchical shading?

Ok, discovered my mistake. I exported as a template, which did not preserve the layers. When I exported as a symbol 3.0, the layers were preserved and now things are rendering as expected.

How I diagnosed:

  • imported the SVG that I had exported as a template back into SF Symbols and noticed that only a single layer was there
  • exported as a symbol and imported that into Xcode, rendered as hierarchical

Bottom line: Export as a symbol, not as a template when importing into Xcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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