I have a very simple class for drawing on the screen following the finger. I want to set up a button to clear all the drawings and allow the user to start drawing again. I can't figure out what to do inside the button's action to 'clear' the drawing.
Asked
Active
Viewed 1,839 times
2 Answers
1
-(void)cancelDrawing
{
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"drawview_blank.jpg"]];
//[anyArrayUsedForDrawing removeAllObjects];
[self setNeedsDisplay];
}

Warif Akhand Rishi
- 23,920
- 8
- 80
- 107
-
I can't add images. This is actually a test of the iOS course I'm following. The only hint the teacher gave us is something like "reset the view deleting all the drawings". – Aleph72 Jun 18 '12 at 17:25
-
hi @Aleph72 great you found out yourself. Calling **setNeedsDisplay** will automatically call **drawRect** method. you have drawing code in the drawRect Method. In this method you could check isYour array empty and if empty return. You dont't need image as you have found out yourself. – Warif Akhand Rishi Jun 19 '12 at 16:19
1
Ok I found out myself how to do it. It was very simple, but you know, I didn't think about that. I had to empty the array containing the drawings and call the [self setNeedsDisplay] method.

Aleph72
- 877
- 1
- 13
- 40