Clear UIView of drawing? Clear UIView of drawing? objective-c objective-c

Clear UIView of drawing?


Reinitialise the path variable and force the view to draw with this newly created empty path. This gives impression of erasing the previous drawn path. In your subclass include this function,

- (void)erase {    path   = nil;  //Set current path nil    path   = [UIBezierPath bezierPath]; //Create new path    [self setNeedsDisplay]; }

Declare this method in the .h file of your subclass. From your view controller class you need to call this method whenever you need to erase the view,

- (IBAction)clearTapped:(id)sender {    [self.subclassedView erase];}

Try it out.

Hope that helps!


IT will surely work.. guaranteed...addition to answer by @Amar and comment by @Josue... thanx to you both

- (void)erase {        path   = nil;  //Set current path nil        path   = [UIBezierPath bezierPath]; //Create new path        incrementalImage = nil;        [self setNeedsDisplay];   }