简体   繁体   中英

Can I use SVG files in Xcode projects?

I have downloaded "Add-to-Apple-Wallet" button from Apple website. But the format given is SVG.

The guidelines says that I should not modify the image. Should I use the SVG as it is in the project or can I convert it to pdf or png using some tool like sketch.

Starting from Xcode 12 SVG support was added in xcassets file.

在此处输入图片说明

There are multiple options for displaying svg images on iPhone:

The iOS Browser actually renders SVG:

let url = URL.init(fileURLWithPath: Bundle.main.path(forResource: "Add_to_Apple_Wallet_rgb_HB", ofType: "svg")!)
webView.loadRequest(NSURLRequest.init(url: url) as URLRequest)

Or you can use a third party library:

SVGKit The most complete, supports multi path svg's.

PocketSVG Good, storyboard compatible, but you can only load single path svg's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM