Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the UIBezierPath or CGPath from CGContextRef

I have a bezier path inside the current graphics context that I want to store as a UIBezierPath or CGPath. Do you know how to get the path out of a CGContextRef?

like image 274
Logan Shire Avatar asked Feb 17 '23 04:02

Logan Shire


2 Answers

You can copy the context's current path using CGContextCopyPath.

There is no function that copies the clipping path. Indeed, the clipping region won't be defined by a path if you've used CGContextClipToMask.

like image 79
rob mayoff Avatar answered Feb 18 '23 18:02

rob mayoff


You can use the CGContextCopyPath function:

CGPathRef myPath = CGContextCopyPath(context);
like image 41
yonosoytu Avatar answered Feb 18 '23 16:02

yonosoytu