I am trying to have it so when the user taps the screen, a small point appears at that touched point. I need it so that the drawn point remains on the screen in its position instead of being completely redrawn at the new point the user taps the second time, or third time, etc. So basically every time the user taps the screen a point shows at that point and does not disappear the next time the user taps the screen and a new point is made. Here's my code so far:
Code:
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext(); CGContextFillEllipseInRect(context, CGRectMake(point1.x - 5,point1.y - 5, 10, 10));
CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
CGContextDrawPath(context, kCGPathFillStroke);
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
point1 = [touch locationInView:self];
point1xCoordinate = point1.x;
point1yCoordinate = point1.y;
[self setNeedsDisplay];
}
Any help is very much appreciated.