ios - 删除 CGContextAddPath 之后的路径
<p><p>我想知道在我使用 CGContextAddPath 添加 CGPath 之后,是否有办法从我的上下文中删除它,这样我的绘图命令就不再局限于路径尺寸。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您应该使用 <code>CGContextBeginPath(...)</code> 从指定的上下文中删除之前添加的路径。</p>
<p>来自<a href="https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGContext/index.html#//apple_ref/c/func/CGContextBeginPath" rel="noreferrer noopener nofollow">Apple's documentation</a>的方法的讨论:</p>
<blockquote>
<p>A graphics context can have only a single path in use at any time. If the specified context already contains a current path when you call this function, Quartz discards the old path and any data associated with it.</p>
<p>The current path is not part of the graphics state. Consequently, saving and restoring the graphics state has no effect on the current path.</p>
</blockquote>
<p>类似于下面:</p>
<pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddPath(context, ellipsePath);
CGContextDrawPath(context, kCGPathFill);
CGContextBeginPath(context);
CGContextAddPath(context, strokePath);
CGContextDrawPath(context, kCGPathStroke);
</code></pre></p>
<p style="font-size: 20px;">关于ios - 删除 CGContextAddPath 之后的路径,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/11366689/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/11366689/
</a>
</p>
页:
[1]