Vectorized Assets for iOS with PDF
As mobile operating systems continously grows up, the market is filled with more and more devices, apps with different specs, including device capabilities, screen sizes, and so on. Developing apps, with those conditions now becomes complex tasks, because developers are responsible of making their apps work with all of them. While Android, with multiple-hardware spec came in concept, has its own mechanism for handling resources corresponding to hardware specs, iOS has similar problem with every new generation of iPhone and iPad.
We had origin assets, used in non-retina device like iPhone 3G. Then when retina-era comes, Apple introduces @2x assets to avoid blurry images inside apps. Now with iPhone 6 and iPhone 6 Plus, it requires us to have @3x assets, and who knows, if they want us to have @4x one in somewhere in future?
So, another solution for such situations is using vector assets. Android 5.0 introduces support for VectorDrawable, which basically a way for Android to render SVG images, so it can scale nicely in every resolution.
With iOS, Apple has another technique. Now we can use a PDF, which is kind-of vector assets, to be set as our image.
Create Project
Now we will create a new project to demonstrate this feature. It requires XCode 6 to do it.
[om/content/images/2015/08/VectorPDF_Size.png)
Now File -> Save As and make a Photoshop PDF, choose Smallest Size options to reduce file size:
[om/content/images/2015/08/VectorPDF_Save.png)
Now we can drag our PDF directly into Images.xcassets:
[om/content/images/2015/08/VectorPDF_Drag.png)
Change Scale Factors to Single Vector:
[
