title: how to draw a picture in iPhone with Quartz2d
body: <p>I'm studying Quartz now and want to do a demo like this:
  when your finger moves on the iPhone screen, it shows the track in red color。
  The code is like:</p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  UITouch *touch = [touches anyObject];
  _firstPoint = [touch locationInView:self];
  }
  
  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
  UITouch *touch = [touches anyObject];
  _endPoint = [touch locationInView:self];
  [self setNeedsDisplay];
  _firstPoint = _endPoint;
   }
  </code></pre>
  
  <p>then </p>
  
  <pre><code>- (void)drawRect:(CGRect)rect {
  
  // Drawing code.
  CGContextRef _context = UIGraphicsGetCurrentContext();
  
  CGContextSetRGBStrokeColor(_context, 1, 0, 0, 1);
  CGContextMoveToPoint(_context, _firstPoint.x, _firstPoint.y);
  CGContextAddLineToPoint(_context, _endPoint.x, _endPoint.y);
  
  CGContextStrokePath(_context);
  }
  </code></pre>
  
  <p>Here,_firstPoint and _endPoint are CGPoint to record positions.
  However, it doesn't show the track.
  I don't know what is the problem.
  Please give any tips.</p>
  
  <p>Finally, I'd like to consultant whether it is right to fulfill such a kind of App.</p>
  
  <p>thanks!</p>