iPadで簡単なフィンガーペインティングアプリケーションを作成して実験しています。画面へのパスを正しく描画できますが、描画されたすべてのパスを画面から完全にクリアするオプションが必要です。私が現在持っているコードはコンテキストをクリアしますが、描画コード ブロックを呼び出すと、すべてのパスが画面に再表示されます。
- (void)drawRect:(CGRect)rect
{
//Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
if(clearContext == 0){
CGContextSetLineWidth(context, 6);
CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);
CGContextAddPath(context, drawingPath);
CGContextStrokePath(context);
}
if(clearContext == 1){
//This is the code I currently have to clear the context, it is clearly wrong
//Just used as experimentation.
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextAddPath(context, drawingPath);
CGContextStrokePath(context);
clearContext = 0;
}
}