I am trying to set an image tint in SwiftUI Image
class
For UIKit, I can set image tint using
let image = UIImage(systemName: "cart")!.withTintColor(.blue)
but I cant find such settings in swiftui docs
The absolute simplest way to change colors of images (or icons in this case) is to use the SF Symbols where applicaple. This is a set of symbols Apple provides that can easily be used in your own app. You can download an app to help you find the correct symbol for you needs here.
On new swiftUI
for set tint
use:
Image("ImageName") .foregroundColor(.red)
Depending on the source image you may also need an additional rendering mode modifier:
Image("ImageName") .renderingMode(.template) .colorMultiply(.red) // or Image("ImageName") .colorMultiply(.blue)
And you can read this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With