0
경로를 만든 다음 즉시 검색하고 수정하려고합니다. 문제는 경로가 올바르게 생성되고 표시되지만 그 경로를 검색하여 추가로 수정할 수 없다는 것입니다.여러 단계로 경로 만들기
업데이트 : 두 번째 함수에서 CGContextClosePath를 호출하면 컴파일러에서이 오류를 반환합니다. : CGContextClosePath : 현재 점이 없습니다. 기본적으로 이전 경로를 인식하지 못하므로 닫을 수 없습니다. 어떤 조언도 높게 평가 될 것입니다! 감사! 스트로크하기 전에 다시 컨텍스트 경로를 추가
//Defined at the very beginning outside the functions
CGMutablePathRef _path;
//First function
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), BrushSize);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1.0);
_path = CGPathCreateMutable();
CGContextAddPath (context, _path);
CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
CGContextStrokePath(context);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//Second function
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); //kCGLineCapSquare, kCGLineCapButt, kCGLineCapRound
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), BrushSize); //1.0); // Brush size
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
CGContextSetRGBFillColor(context, 1.0, 0.4, 1.0, 1.0);
CGPathRef pathFill = CGPathCreateCopy (_path);
CGContextAddPath (context, pathFill);
CGContextClosePath(context);
CGContextFillPath(context);
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
작동하지 않습니다 ... – jeddi
감사하지만 작동하지 않습니다 (편집 된 질문을 참조하십시오). 건배 – jeddi
최종 목표는 닫힌 경로를 채우는 것이므로이 접근법을 사용할 수 없습니다 ... – jeddi