作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 SF Symbols 导出为 pdf 图标,并将默认的白色更改为黑色。我想将黑色改回白色。我发现 .colorInvert
可以做到这一点,但是当我将 Image
放入 Button
时,它再次设置为黑色。
import SwiftUI
#if os(macOS)
extension Image {
static func sfSymbol(_ systemName: String) -> some View {
Image(systemName)
.resizable()
.aspectRatio(contentMode: .fit)
.colorInvert()
.frame(height: 20)
}
}
struct ImageView_Previews: PreviewProvider {
static var previews: some View {
Group {
Image.sfSymbol("square.and.arrow.down.fill")
Button(action: {}, label: { Image.sfSymbol("square.and.arrow.down.fill") })
}
}
}
#endif
最佳答案
我实际上遇到了同样的问题,并且发现您必须将图标的属性检查器中的渲染模式更改为“模板图像”。
关于swiftui - 如何在 SwiftUI 中更改 pdf 图标的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58581492/
我是一名优秀的程序员,十分优秀!