Detecting when a UIView and a line touches

Discussion in 'iOS Development' started by Spreche, Apr 12, 2009.

  1. Spreche

    Spreche Member

    Joined:
    Dec 27, 2007
    Messages:
    164
    Likes Received:
    0
    Device:
    iPhone
    I was wondering if there is a any possible way to detect when a subclass of UIView touches a line that is connected through a group of points.
    Code:
         CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
         CGContextSetLineWidth(context, 8.0);
         CGContextSetLineCap(context, kCGLineCapSquare);
         const CGPoint points[] = 
         {
              CGPointMake(40, 30),
              CGPointMake(40, 115),
              CGPointMake(10, 115),
              CGPointMake(10, 345),
              CGPointMake(40, 345),
              CGPointMake(40, 410),
              CGPointMake(280, 410),
              CGPointMake(280, 345),
              CGPointMake(310, 345),
              CGPointMake(310, 115),
              CGPointMake(280, 115),
              CGPointMake(280, 30),
              CGPointMake(40, 30),
              
         };
         
         CGContextAddLines(context, points, 13);
         CGContextStrokePath(context);
    
    The figure made above comes out to be an 8-sided figure. I want to know if its possible to detect when the UIView subclass touches one of the sides. Would I have to make the UIView a CGLayer for it to be easier? Then detect when they touch that way?
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Remove the link from your signature.

Share This Page