Note that there are some explanatory texts on larger screens.

plurals
  1. POStretchy UIBezierPath line?
    text
    copied!<p>I want to draw a straight line with my finger that automatically sizes based upon how far away I am from the point of origin. </p> <p>So if I touch the screen in the middle and slide my finger out a line appears to 'stretch' and pivot around the point of orgin as my finger moves on the screen. WHhen I lift my finger. The Destination Point should finalize and create a line. I can drag my finger across the screen and 'Draw' on the screen but that's not what I am wanting to do.</p> <p>I thought UIBeizerPath moveToPoint would help but it just messes things up.</p> <p>What am I doing wrong?</p> <pre><code>- (id)initWithFrame:(CGRect)frame { //default line properties myPath=[[UIBezierPath alloc]init]; myPath.lineCapStyle=kCGLineCapRound; myPath.miterLimit=0; myPath.lineWidth=lineWidth; brushPattern=[UIColor blackColor]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint curPoint = [[touches anyObject] locationInView:self]; lastPoint = curPoint; [myPath moveToPoint:lastPoint]; [pathArray addObject:myPath]; [self setNeedsDisplay]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint curPoint = [[touches anyObject] locationInView:self]; myPath.lineWidth=lineWidth; brushPattern=[UIColor redColor]; //red to show it hasn't been added yet. [myPath moveToPoint:tempPoint]; [self setNeedsDisplay]; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint curPoint = [[touches anyObject] locationInView:self]; myPath.lineWidth=lineWidth; brushPattern=[UIColor blackColor]; //finalize the line with black color [myPath addLineToPoint:curPoint]; [self setNeedsDisplay]; } </code></pre>
 

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