vector images in iOS using xcassets

Ankit Kumar Gupta
2 min readDec 2, 2016

--

Its been a tough job to get multiple images for each resolution and also we never know when next 4x images might come in, to make app compatible for all devices we can use vector images in xcassets, which only impacts compile time and not at runtime. These pdfs are changed into png files during compile time. Also you can use the same asset and change its tint color to re-use it.

Using vector image

Step 1: get vector image and convert it to pdf file.

Step 2: In your project add “New Image Set” and in inspector
- set Scale as “Single Scale”
- set Render As “default”

Step 3: use it as you normally use an asset

in storyboard by name
in code by name

Changing color of vector image

Step 1: In your project add “New Image Set” and in inspector
— set Scale as “Single Scale”
— set Render As “TemplateImage”

Step 2: use it as you normally use an asset

Step 3: change its tint color

--

--