18

SVG image assets supported in Xcode 12

 3 years ago
source link: https://sarunw.com/posts/svg-image-assets-supported-in-xcode12/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

In Xcode 12, Apple finally added support for SVG image assets. Under the hood, it should work the same way as PDF format that serve us for all these years. Despite no obvious techincal benefit, this change bring a lot of side benefits.

Finally, we can use the same vector format that has been used across designer spaces. Do you remembered the first time you told a designer you want PDF format for your image assets? Nothing wrong with PDF format, but it is just not a format that most people use to represent vector image.

Less work for designers

Your designers doesn't have to export and maintain an extra format for iOS anymore.

Remove the need of designers or converting tools

Most vector stock out there only support SVG. In the past you might need to beg a designer or find a tool to do a convertion, but this would be no longer a case.

Most of the time, SVG are smaller than PDF. So, your codebase would be smaller.

You can treat it the same way as PDF format. Drag the file into your Assets Catalog and change the Scales value to Single Scale .

RvYr6vB.png!web Adding SVG to Asset Catalogs BvmMbun.png!web Xcode 12 Release Notes
Added support for Scalable Vector Graphic (SVG) image assets. These preserve their vector representation with deployment targets of macOS 10.15 or later, iOS 13 or later, and iPadOS 13 or later. (18389814)

You might misguid by the release note that the SVG support is only for macOS 10.15 or later, iOS 13 or later, and iPadOS 13 or later. In reallity the SVG support all the way back.

The SVG support all the way back.

If you read carefully, the function that required those deployment target is Vector data preservation . So, if you don't need to dynamically scale your image in runtime, you can safely convert all your image assets to SVG.

If your assets don't use this Preserve Vector Data , you can use SVG format without any restriction.

2Y3eayy.png!web Non preserve vector data asset

SVG Support is a welcoming change that you might have missed during WWDC 2020. This small change bring a lot of hidden benefit to the platform and the best thing is you can start adopting it right away (withof course).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK