I have a grid of small (30X30 size) UIViews & I am drawing a line over them by tapping two points on the screen as startpoint & endpoint by using the code below:
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[] = {244.0f/255.0f, 226.0f/255.0f, 119.0f/255.0f, 0.8};
CGColorRef color = CGColorCreate(colorspace, components);
CGContextSetStrokeColorWithColor(context, color);
CGContextSetLineWidth(context, 20.0);
CGContextMoveToPoint(context, startPoint.x, startPoint.y);
CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
CGContextStrokePath(context);
CGColorSpaceRelease(colorspace);
CGColorRelease(color);
Tapping two points on screen & drawing a line is working fine but how do I get all the views intersected by the line? I want to get these views in the touches ended method.
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint pt = [[touches anyObject] locationInView:alphabetView];
UIView *touched = [alphabetView hitTest:pt withEvent:event];
CGPoint p = touched.center;
// code here to get view list.
}
Any help would be appreciated.