2012-07-06 117 views
1

後,我在想,如果有一種方法後,我用CGContextAddPath這樣,我的繪圖命令不再侷限於路徑尺寸後來加入的是從我的上下文中移除CGPath。刪除路徑CGContextAddPath

回答

0

沒有辦法,一旦它在上下文中刪除路徑。只需重繪沒有特定的路徑。

1

您應該使用CGContextBeginPath(...)從指定的範圍內刪除以前添加的路徑。

探討的方法,從Apple's documentation

圖形上下文可以具有在使用中在任何時候只有一個路徑。如果在調用此函數時指定的上下文已經包含當前路徑,則Quartz會丟棄舊路徑以及與其關聯的所有數據。

電流路徑是不是圖形狀態的一部分。因此,保存和恢復圖形狀態對當前路徑沒有影響。

類似如下:

CGContextRef context = UIGraphicsGetCurrentContext(); 

CGContextAddPath(context, ellipsePath); 
CGContextDrawPath(context, kCGPathFill); 

CGContextBeginPath(context); 

CGContextAddPath(context, strokePath); 
CGContextDrawPath(context, kCGPathStroke);