0

In my app, I want to draw a dot on the screen (where the user touches). After adding it, I save the incrementalImage and the next point will be added to this image.

The problem is, that the first point doesn't appear. What am I missing?

    UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 0.0);

    if (!self.incrementalImage) // first time; paint background white
    {
        UIBezierPath *rectpath = [UIBezierPath bezierPathWithRect:self.bounds];
        [[UIColor whiteColor] setFill];
        [rectpath fill];
    }
    [self.incrementalImage drawAtPoint:CGPointZero];

    CGContextFillEllipseInRect(UIGraphicsGetCurrentContext(), CGRectMake(point.x - roundf(_lineWidth / 2.0), point.y - roundf(_lineWidth / 2.0), _lineWidth, _lineWidth));

    self.incrementalImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
Levi
  • 7,313
  • 2
  • 32
  • 44
  • first time incrementalImage is nil so this is no operation [self.incrementalImage drawAtPoint:CGPointZero]; Move it after the line where you initialised incrementalImage. – msk Apr 03 '13 at 09:33
  • Shouldn't my ellipse be drawn on my UIView even if that image is nil? – Levi Apr 03 '13 at 09:41
  • yes what I am saying is that first time this line will not work [self.incrementalImage drawAtPoint:CGPointZero]; – msk Apr 03 '13 at 09:43

0 Answers0