나는 CGContext 아래와 같이 경로 (이 SwbPlate라는있는 CustomView 클래스에서 발생와 무승부의 이미지를 사용자가 클릭 어떠했는지를 감지하기 위해 노력하고있어이 그려있는 UIImage의 접촉을 가져 오기 :CGContext
SwbPlateImage * image;
CGFloat startAngle;
CGFloat endAngle;
CGContextRef context = UIGraphicsGetCurrentContext();
for (image in plateImages) {
endAngle = [EntGeometry pointToRadian:[image endPoint] withCenterPoint:CGPointMake(self.bounds.size.width/2 , self.bounds.size.height /2)];
startAngle = [EntGeometry pointToRadian:[image startPoint] withCenterPoint:CGPointMake(self.bounds.size.width/2 , self.bounds.size.height /2)];
imageToDraw = [image plateImg];
NSLog(@"%@", image);
CGContextSaveGState(context);
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, self.bounds.size.width/2 , self.bounds.size.height/2);
CGPathAddArc(path,
NULL,
self.bounds.size.width/2,
self.bounds.size.height/2,
(self.bounds.size.width/2),
endAngle,
startAngle,
0);
CGPathCloseSubpath(path);
CGContextAddPath(context, path);
CGContextClip(context);
CGContextTranslateCTM(context, 0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, rect, [imageToDraw CGImage]);
CGContextRestoreGState(context);
//RVE MOD
image.imageContext = context;
그런 다음 사용자가이 맥락에서 지점에 이동 터치가 있는지 확인하려고하지만 당신이 사용할 수없는 당신이 컨텍스트를 할당하는 SwbPlateImage 지역 변수가 나에게 보인다
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
NSArray *allTouches = [touches allObjects];
UITouch *touch = [allTouches objectAtIndex:0];
SwbDragProduct*dragProd;
for (UIView *view in self.view.subviews) {
if ([view isKindOfClass:[SwbPlateView class]] &(CGRectContainsPoint([view frame], [touch locationInView:self.view]))) {
NSLog(@" We touched in the PLATE");
for (SwbPlateImage *imgView in plateView.plateImages){
if(CGContextPathContainsPoint(imgView.imageContext, [touch locationInView:self.view],kCGPathFillStroke)){
NSLog(@" We Touched within the IMAGE");
}
}
}
하지 내 대답 도움을 했습니까? – applefreak