1
나는 ipad에 간단한 손가락 페인팅 응용 프로그램을 만드는 것을 실험하고 있습니다. 화면 경로를 올바르게 그릴 수 있지만 모든 그려진 경로의 화면을 완전히 지울 수있는 옵션이 필요합니다. 현재 코드에서 컨텍스트를 지우지 만 드로잉 코드 블록을 호출하면 모든 경로가 화면에 다시 나타납니다.CGContextRef를 지우는 방법은 무엇입니까?
- (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;
}
}
완벽하게 작동합니다 ... 감사합니다! – Michael