简体   繁体   中英

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?

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 .

您可以使用CGContextCopyPath函数:

CGPathRef myPath = CGContextCopyPath(context);

Swift 4.0 and higher

You can just use for coping the path.

let copy = context.path

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