gpt4 book ai didi

swiftui - 如何在 SwiftUI 中更改 pdf 图标的颜色

转载 作者:行者123 更新时间:2023-12-02 00:12:18 24 4
gpt4 key购买 nike

我将 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

PDF 图标:square.and.arrow.down.fill.imageset

enter image description here

最佳答案

我实际上遇到了同样的问题,并且发现您必须将图标的属性检查器中的渲染模式更改为“模板图像”。

关于swiftui - 如何在 SwiftUI 中更改 pdf 图标的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58581492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com