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

resizeToFit ignores viewBox #180

Open
stefanhaustein opened this issue Mar 30, 2021 · 2 comments
Open

resizeToFit ignores viewBox #180

stefanhaustein opened this issue Mar 30, 2021 · 2 comments

Comments

@stefanhaustein
Copy link

Description of the Issue
Calling resizeToFit seems to ignore the viewBox specified in the svg image and use the "actual" size of the SVG contents (while ignoring the offset, leading to rendering potentially outside of the specified rect).

Sample SVG
Faulty rendering with resizeToFit: the green box is displayed outsider of the UIView, which has a grey background, see screenshot

 <svg viewBox="0 0 30 30">
      <rect x="10" y="10" width="10" height="10" fill="#00ff00"/>
 </svg>

Broken

Working as expected:
When the viewBox is filled with content, scaling seems to work as expected; all three boxes are scaled to match the size of the UIView containing the SVGLayer

.

 <svg viewBox="0 0 30 30">
      <rect x="0" y="0" width="10" height="10" fill="#ff0000"/>
      <rect x="10" y="10" width="10" height="10" fill="#00ff00"/>
      <rect x="20" y="20" width="10" height="10" fill="#0000ff"/>
 </svg>

Working

@spase84
Copy link

spase84 commented Aug 25, 2021

I have same issue.
Have you found any solutions?

@jerry1230
Copy link

same issue too

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

3 participants