6

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.

Rob
  • 2,243
  • 4
  • 29
  • 40
Tamil
  • 1,173
  • 1
  • 13
  • 35
  • is there any pblm u facing – Anbu.Karthik Feb 08 '17 at 11:23
  • 1
    People suggested that SVG is not natively supported in iOS and suggested to convert svg to pdf. Neither i could find any official link that talks about this. my app supports from iOS 8 and worried about performance on lower devices. – Tamil Feb 08 '17 at 11:31
  • It is not a big deal, just convert it to PNG and add it to the default imageset you have. – Mahmoud Fayez Feb 08 '17 at 11:36
  • 2
    Xcode converts vector graphics to png at compile time. A few years ago Xcode supported only pdf, not svg, but since the download gives you svg, I'd try using it first. See [this answer](http://stackoverflow.com/a/25818846/335858) for details. – Sergey Kalinichenko Feb 08 '17 at 12:22

2 Answers2

8

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

enter image description here

Ramis
  • 13,985
  • 7
  • 81
  • 100
1

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.

Karlo A. López
  • 2,548
  • 3
  • 29
  • 56