title: How to implement an eraser in a simple graphics editor?
body: <p>I want to create simple graphics editor on iOS, in which I use bitmap graphics context and bezier paths to convert lines to pictures. </p>
  
  <p>I didn't find a way to create an <em>eraser</em>.</p>
  
  <p>Do you have any ideas?</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect {
      [[UIColor blackColor] setStroke];
  
      CGContextRef aRef = UIGraphicsGetCurrentContext();
  
      aPath.lineWidth = 5;
      [aPath stroke];
      [[[UIColor blackColor] colorWithAlphaComponent:0] setStroke];
      bPath.lineWidth = 5;
      [bPath stroke];
     movesss= CGBitmapContextCreateImage(aRef);
      if (movesss==NULL) {
          NSLog(@"null =(");
      }
  }
  
  -(void)moveTo:(CGPoint)pos {
      if(del){
          [bPath moveToPoint:pos];
      }
      else{
          [aPath moveToPoint:pos];
      }
  }
  
  -(void)cret{
      aPath=[[UIBezierPath bezierPath] retain];
      bPath=[[UIBezierPath bezierPath] retain];
      del=NO;
  }
  
  -(void)lineTo:(CGPoint)pos {
      if(del){
          [bPath addLineToPoint:pos];
      }
      else{
          [aPath addLineToPoint:pos];
      }
      [self setNeedsDisplay];
  }
  
  -(void)imgf{
      UIImage *imageToSave=[[UIImage imageWithCGImage:movesss] retain];
  
     UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
      UIImageView *trew=[[UIImageView alloc] initWithFrame:[self frame]];
      [trew setBackgroundColor:[UIColor greenColor]];
      [trew setImage:imageToSave];
      [self addSubview:trew];
  }
  
  -(void)swittch{
      del=!del;
  }
  </code></pre>
  
  <p><br>
  What's wrong here?</p>