views:

50

answers:

1

Is it possible to create a CGPath from a given file?

SVG would be preferred, but anything will work.

+1  A: 

Yes. It is possible. I haven't done this, but because SVG uses paths itself, it seems that mapping an SVG path to a CGPath would be something possible/manageable. The question at that point becomes how motivated are you? I didn't see any Objective-C libraries that already do this in a cursory google search, but it may be out there. I did see a Java implementation, that you could probably port.

Considering the lack of obvious solutions on the web, I would guess this isn't a very common need for app devs. There's probably a better/easier way to solve the problem at hand. If all you want is to display an SVG image, you could just embed a webview and let WebKit render it for you.

Matt Long
I don't want just display the svg. I need fairly complex paths in some views. and as I want the user to be able to change this path, it would be nice, if they just could paint them in their favorite vector program.
vikingosegundo
That makes sense. Unfortunately, it looks like there aren't any Objective-C implementations. I've seen some C++ libraries, but they seem pretty massive and would be hard to port. To support the full SVG spec is probably doable, but time consuming. Good luck.
Matt Long