2013-09-27 61 views
0

我已經在UIView(它的背景是透明的)上使用UIBezierPath實現繪圖線。清除UIView繪圖屏幕抓圖截圖不能正常工作

對於引出配線,我已經使用以下代碼中- (void)drawRect:(CGRect)rect方法: -

UIBezierPath *_path = [pathArray objectAtIndex:0]; 
[currentColor setStroke]; 
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0]; 

這裏pathArray是多發性UIBezierPath對象數組。

擦除平局,我用下面的代碼在- (void)drawRect:(CGRect)rect方法: -

UIBezierPath *_path = [pathArray objectAtIndex:10]; 
[[UIColor clearColor] setStroke]; 
[_path strokeWithBlendMode:kCGBlendModeClear alpha:1.0]; 

以上兩種方法運作良好,而在透明的UIView繪製。但是,當我用白色背景色繪製UIView時,出現了我已經擦除繪製的黑色。捕獲繪圖視圖的截圖時也出現同樣的問題。任何解決方案

查看下面的同一張圖的截圖,你會明白的。

回答

1

我已經自己解決了問題。我寫的代碼擦除繪圖像爲:

UIBezierPath *_path = [pathArray objectAtIndex:10]; 
[drawingView.backgroundColor setStroke]; 
[_path strokeWithBlendMode:kCGBlendModeCopy alpha:1.0]; 

在這裏,你必須設置strokeWithBlendModekCGBlendModeCopy,而不是kCGBlendModeClear和使用的視圖背景顏色在其上繪製。