Note that there are some explanatory texts on larger screens.

plurals
  1. POGet touches in UIImage drawn with CGContext
    primarykey
    data
    text
    <p>I'm trying to detect wether a user clicks on a image in draw with a CGContext and a path as below (this happens in a customview class called SwbPlate:</p> <pre><code> 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; </code></pre> <p>Then i try to see if the user has touches moved on a point within this context but this does not seem to work</p> <pre><code>- (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]] &amp;(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"); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload