使用CGPathRef屏蔽CGContext?

Fra*_*ank 8 core-graphics objective-c cgpath

我正在使用CGContext进行绘图.我目前正在使用像这样的png文件来屏蔽绘图:

UIImage * myImage = [UIImage imageNamed:@"frame.png"];
CGContextRef context = UIGraphicsGetCurrentContext ();
CGContextClipToMask(context, self.view.bounds, myImage.CGImage);
Run Code Online (Sandbox Code Playgroud)

这很好,但现在我想使用现有的CGPathRef作为我的掩码.我应该看看如上所述将CGPathRef转换为UIImage和掩码吗?如果是这样,我将如何进行转换? - 或者 - 有更好的方法来解决这个问题吗?

cxa*_*cxa 12

CGContextAddPath(context, yourPath);
CGContextClip(context);
Run Code Online (Sandbox Code Playgroud)