Я экспортирую символы 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
Значок PDF: square.and.arrow.down.fill.imageset
