SDWebImageSwiftUI: [Color] AnimatedImage tinting not getting applied
Hello,
I am trying to apply a tint to an svg image but it seems no matter what I try none of them work.
I have already tried applying each modifier individually but I just wanted to show what I have tried.
Device
- iPhone 15 Prox Max
- iOS 17.5
AnimatedImage(url: <svg_url>)
.resizable()
.renderingMode(.template)
.onViewCreate(perform: { view, image in
view
.tintColor = .green
})
.tint(.green)
.accentColor(.green)
.foregroundStyle(.green)
.colorMultiply(.green)
.frame(width: 32, height: 32)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16
Supported by SDWebImage’s AnimationTransformer feature, see more in https://github.com/SDWebImage/SDWebImage/pull/3761
This feature is not only about
tint, you can customize each animation frame to whatever you want, like scale it down, flip down, apply CIFilter blur, etc…More powerfulFor
WebImgeyou can still use tintColor from UIKit/SwiftUI, because it actually use UIKit’s build box for rendering (Apple’s own implementation).But for
SDAnimatedImageyou must use the custom API because of implementation details is really different from how UIKit’s animation rendering. (We use custom CALayer and custom draw for better performance)@dreampiggy I tested
WebImageand it works when applying tint, the problem with this is that it if I use it within an animated context which is what I am doing at the moment. It doesn’t animate, it seems to be fixed on the page and the content animates around it.