Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to apply tint to SVGView? #59

Open
NikSrg opened this issue Jan 17, 2024 · 3 comments
Open

Question: How to apply tint to SVGView? #59

NikSrg opened this issue Jan 17, 2024 · 3 comments

Comments

@NikSrg
Copy link

NikSrg commented Jan 17, 2024

Hi. I just started to use SVGView. I need to apply a tint to the svg image. How can I?

I tried unseccessfully:

SVGView(data: data)
                .foregroundColor(.blue)

SVGView(data: data)
                .tint(.blue)

SVGView(data: data)
                .background(Color.blue)

Thanks for any advice.

@Zulqurnain24
Copy link

I have same question as facing the same problem

@petterobam
Copy link

+1, me too.

@missingems
Copy link

missingems commented Nov 30, 2024

A bit unintuitive, but I have found a way to apply a "tint" color by masking your SVG on a color. This is also more performant than setting the fill color to every shape via a loop imperatively.

@Zulqurnain24 @petterobam @NikSrg tagging y'all in case you still looking for a solution.

ZStack {
  if let imageData {
    tintColor.mask {
      SVGView(data: imageData)
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants