我正在寻找一种方法来更改 swiftui 中 sf 符号图标的笔触/填充颜色。
我已经尝试过,.background(Color.red)但这只是改变了整个图标的背景(没有改变应用于实际图标本身),正如暗示的那样,然后我也尝试.foregroundColor(Color.red)了对图标没有任何作用。
内容视图的内容如下
var body: some View {
Image(systemName: "person.circle").foregroundColor(.red)
}
Run Code Online (Sandbox Code Playgroud) 在 WWDC 2021 上,Apple 宣布了 SF Symbols 3,它将在 iOS 15 和 macOS 12 中支持新的多色 SF Symbols。
新的色彩渲染模式,通过图层注释增加符号的深度和强调
https://developer.apple.com/design/ human-interface-guidelines/sf-symbols/overview/
在 UIKit 和 Swift 中创建这样的图像的语法是什么?
let configuration = UIImage.SymbolConfiguration(pointSize: 18, weight: .regular, scale: .large)
// set colors...?
let image = UIImage(systemName: "1.circle", withConfiguration: configuration)
Run Code Online (Sandbox Code Playgroud)
如何使用 UIKit 中新的hierarchical、palette、 和multicolor渲染模式?
这些新的渲染模式和颜色在 SF Symbols 3 应用程序中可见: