Open aram-azbekian opened 3 years ago
@aram-azbekian any chance you found a solution?
@gunhansancar @aram-azbekian Any chance you found a solution? :P
@orelsgitconstru Not really unfortunately. I ended up converting the Node
to regular UIImage
so that I can use it in anywhere. It is not optimal but at least it works.
node.toNativeImage(size: Size(width, height))
Here also their toNativeImage
method sets to scale to 1.0
for some reason so you have to multiple width, height
of the node with actual screen.scale
to end up with pixel perfect image.
Like the following:
let size = node.bounds?.size() ?? Size.zero
let scale = UIScreen.main.scale
let width = size.w * scale
let height = size.h * scale
let image = try node.toNativeImage(size: Size(width, height))
@aram-azbekian any chance you found a solution?
I found a solution. Inside your svg, first row, there's width and height. Change them.
@orelsgitconstru Not really unfortunately. I ended up converting the
Node
to regularUIImage
so that I can use it in anywhere. It is not optimal but at least it works.
node.toNativeImage(size: Size(width, height))
Here also their
toNativeImage
method sets to scale to1.0
for some reason so you have to multiplewidth, height
of the node with actualscreen.scale
to end up with pixel perfect image.Like the following:
let size = node.bounds?.size() ?? Size.zero let scale = UIScreen.main.scale let width = size.w * scale let height = size.h * scale let image = try node.toNativeImage(size: Size(width, height))
Nice idea, wow.
Hi! I have a small project where I'm trying to open SVG image using Macaw library. In that project I make a SVGView and set its contentMode parameter to ".scaleAspectFit". As far as I know, the only condition for it to work is availability of "width" and "height" parameters in SVG XML. But it just doesn't work and the image is presented in its original scale
So, this is a code snippet where I create a view:
and attached below is the image example from the project
Thanks in advance. Let me know if you need anything else. svg-5.svg.zip