私は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