I export SF Symbols to pdf icons and default white color changed to black.
I would like to change the black color back to white.
I found that .colorInvert
do it but when I put Image
into Button
it set black again.
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 icon: square.and.arrow.down.fill.imageset