1
내 응용 프로그램에서는 UIImagePickerController
을 사용하여 사진을 찍었습니다. 사진을 찍은 후에는 손가락으로 일부 선을 그려야하기 때문에 UIImageView
을 사용하여 그릴 수 없습니다.UIImage를 CurrentContext에 그리기
- (void)drawRect:(CGRect)rect {
[self.myimage drawInRect: rect];
//Disegno rettangolo del tag
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(myContext, 0.5, 0.5, 0.5, 1.0);
CGContextSetLineWidth(myContext, 3.0f);
CGContextAddPath(myContext, pathTouches);
CGContextStrokePath(myContext);
}
하고있는 touchesMoved : 나는 무승부 RECT 방법이 코드를 작성한이를 위해
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint locationInView = [touch locationInView:self];
// Draw a connected sequence of line segments
CGPoint addLines[] =
{
//....
//some lines
};
CGMutablePathRef newPath = CGPathCreateMutable();
CGPathRelease(pathTouches);
pathTouches = CGPathCreateMutableCopy(newPath);
CGPathRelease(newPath);
CGPathAddLines(pathTouches, NULL, addLines, sizeof(addLines)/sizeof(addLines[0]));
[self setNeedsDisplay];
}
는 정확한 내 손가락을 이동하거나,이 때마다 [self setNeedsDisplay];
를 호출하는 것입니다 이 작업을 수행하는 더 좋은 방법입니까?
안녕하세요, 코드 덕분에, 내 애플 리케이션을 통해 간단한 uiview에 그려려고했지만 작동하지 않습니다 ... 당신이 나를 도울 수 있습니까 ?? 감사합니다. – ghiboz
@ Rahul Vyas이 문제를 해결할 수 있도록 도와 줄 수 있습니까? http://stackoverflow.com/q/9850772/434898 –