-
Notifications
You must be signed in to change notification settings - Fork 232
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
How to convert UIBezierpath to SVG? #194
Comments
You'll need to explain how the "coloring process" works. If your paths stay as |
Hello, Thank you for your response first of all. Here is my code for coloring process. I am creating CAShapeLayers from SVGBezierPaths then fill inside of them. I want to save result of coloring process as SVG. Is there any way to convert colored CAShapeLayers to SVG?
|
You'll have to iterate over the path array(and change its type to something like let attributeSet = SVGMutableAttributeSet()
let paths = shapeLayers.map { layer in
let path = paths[shapeLayerIndices[layer]]
let newPath = path.pathBySettingSVGAttributes(["fill": layer.backgroundColor])
attributeSet.set(attributes: path.svgAttributes, forPath: newPath.CGPath)
return newPath.CGPath
}
let svgString = SVGStringFromCGPaths(updatedPaths, attributeSet) I haven't actually compiled the above, but the general idea should work. |
Thanks a lot! I will try it and share the results. |
I had the same problem, and I modified the code myself to keep it from crashing
|
@CodeForRabbit It'd be great if you could make a PR with that |
fixed via #214 |
Hello,
I am trying to create a coloring app. I can read svg image and fill their backgrounds. I want to save my UIBezier paths as svg after coloring process is done. I saw the function
SVGStringFromCGPaths
path I could not figure out how to set AttributeSet of svg? A short explanation or a small examples would be great.Thanks,
The text was updated successfully, but these errors were encountered: