Wis*_*uck 7 iphone core-graphics cgcontext
我正在绘制CGContext并使用基于CGImageRef的掩码:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClipToMask(context, rect, _firstMaskImageRef);
CGContextSetFillColorWithColor(context, color);
CGContextFillRect(context, rect);
Run Code Online (Sandbox Code Playgroud)
我有第二个掩码,然后我想切换到:
CGContextClipToMask(context, rect, _secondMaskImageRef);
CGContextSetFillColorWithColor(context, color); // color has changed FWIW
CGContextFillRect(context, rect); // as has rect
Run Code Online (Sandbox Code Playgroud)
但是,这会交叉两个蒙版而不是替换第一个蒙版.
你如何(如果可以的话)清除或重置CGContext的剪贴蒙版?
use*_*321 17
您可以在设置剪贴蒙版之前保存图形状态,然后重置它,如下所示:
CGContextSaveGState (context);
...Set your first clipping mask, fill it, etc.
CGContextRestoreGState (context);
...Do other stuff
Run Code Online (Sandbox Code Playgroud)