I want to change color of svg images. I am using following code, it hides the image and fill the whole image view with the color set.
self.badmintonImgView.tintColor = [UIColor orangeColor];
I need to change the color of image. Please suggest
If the SVG
is in Assets.xcassets
, you can tell Xcode to treat the image as an icon:
First, select your SVG
image in the assets catalog
Then set the render mode to Template Image
Swift
To change the color of an SVG using Swift:
badmintonImgView.image = badmintonImgView.image?.withRenderingMode(.alwaysTemplate)
badmintonImgView.tintColor = UIColor.orange
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