Search code examples
iosswiftswiftuiswift5ipados

SwiftUI - How to change the color of a custom SF symbol in a Text View?


So, I have a Text in a SwiftUI view that has a custom SF symbol in it:

Text("This is some text with a   \(Image(uiImage: UIImage(named: "customSFSymbol")!))  symbol.")

The problem is the following:

I want to make all that view white, but when I add the .foregroundColor(Color.white) to the view, the SF Symbol stays in a black color.

You can see how it looks right now here

Thanks for your help in advance!


Solution

  • You can simply add .renderingMode(.template) to the Image

    Text("This is some text with a   \(Image(uiImage: UIImage(named: "customSFSymbol")!).renderingMode(.template))  symbol.")