SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.14k stars 219 forks source link

Animated Image with rendering mode template #214

Open ghost opened 2 years ago

ghost commented 2 years ago

Officially it is not possible to change the colour of the remote SVG image in AnimatedView with template rendering mode.

workaround:

AnimatedImage(...)
.onViewCreate(perform: { view, _ in
    guard let imageView = view as? UIImageView else {
        return
    }
    imageView.tintColor = foregroundColor.uiColor
})
alexmorral0 commented 2 years ago

We had to use onViewUpdate instead. And also use imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) inside.

dreampiggy commented 2 years ago

I remember that there is one .renderingMode (https://github.com/SDWebImage/SDWebImageSwiftUI/blob/master/SDWebImageSwiftUI/Classes/AnimatedImage.swift#L576) available which do the same thing ?