我将 SF 符号导出为 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2275 次 |
| 最近记录: |