I purchased an icon from thenounproject as an SVG image. I then use a macOS program called Gapplin to export this SVG into a PNG image. It comes out as a 100x100 pixel image.
I then open this PNG image with Preview program and go Tools -> Adjust Size and create 10x10, 20x20 and 30x30 images. I then load these images as 1x, 2x, 3x in Xcode.
Is this the correct method?
You can then select the svg file from the path field and android studio will directly convert the file as a resource. Show activity on this post. You can simply drag and drop your SVG file and export to any devices you need.
For using SVG, you only need to drag them in your assets folder and then you can use them in your project file by using UIImage class named constructor.
No, it's not the optimal solution.
Your current solution works, of course, but it's far from ideal. You are losing (precious!) image quality in doing so (see here for more details). You can improve your worklflow by:
exporting all 3 resolutions from the original SVG file, ensuring you get the best possible PNG bitmap from a vector based image source (using Gapplin or some other image app);
or converting your SVG to PDF and then importing the PDF vector image file in Xcode (last time I checked, Xcode 8 still didn't have direct support for SVG files so we are stuck with good old PDF for now).
Both methods, image quality wise, should produce very similar results and are an improvement from your current workflow.
Regarding app file size, you shouldn't again see a difference from neither method. Even using the last method, Xcode still generates the required assets at build time and, as such, your app will be carrying around the same image/icon set as the first method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With