iossvgpngassets

Which image format i should for ios development native ? SVG or PNG?


I am into iOS development from past 1+ months and what I have experienced is that I have to put images for 1x 2x 3x for iphone and then 2x retina for ipad. One of the experienced designers has sugguested to me to go for svg format as it scales itself according to the screen sizes.

So my elaborated questions are:

  1. Can I use svg instead of png?
  2. Is it necessary to still put images in 2x and 3x for iphone and ipad if I'm using svg?
  3. Will the images in svg scale according to the phone size and not lose quality?

If any other information according to your experience please share.

Thank you.


Solution

  • UPDATE: No longer valid. See Josh Brown's answer - you can use SVG.


    Official iOS Dev documentation says "the PNG format is the one most recommended for use in your apps". You can read it for a lot more information here.

    1. Yes, although the supported file types table doesn't list it. Apple values user experience. SVG scaling consumes a few more CPU cycles which they don't like. PNG rendering is more efficient than SVG.
    2. Yes, Apple explicitly recommends using multiple versions of the image at different sizes. Then scaling can be done from the file having the nearest dimensions.
    3. Refer 1. There are cases like zoom-in / out scenarios where SVGs would be better though.

    You could use vectorized PDFs alternatively. You can read more here. It isn't without limitations, but with vectorized PDFs, Xcode automatically generates scaled versions. That should make life easier. Note that sometimes the scaled results look quite poor.