Reputation: 1304
I am using UIBezierpath to draw a dot on my UIView. I followed this link for the same.
How can i draw a dot on the screen on touchesEnded using UIBezierpath
Now when I am done with this, I am able to add "dots" as much as I can. and adding these dots to an array and showing them on UIView.
If I clean the array on selection of eraser then all dots are getting cleared. I am not able to clear single/particular dot.
This is the method used for adding dots to an array and showing them on UIView.
- (void)drawRect:(CGRect)rect
{
[incrementalImage drawInRect:rect];
for (int i = 0; arrayOfDots.count>i;i++)
{
UIBezierPath *path = [arrayOfDots objectAtIndex:i];
UIColor *color = [arrayOfDotColor objectAtIndex:i];
[color setFill];
[path fill];
}
}
I have eraser to clean the things drawn on UIView. I am able to clean the lines drawn using UIBezierpath, but I am not able to clear the dot drawn using same UIBezierpath.
Eraser is nothing but, I am just picking the white colour and drawing the same white colour on my current view.
here is the code for eraser.
self.strockColour = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0f];
[objBezierpath setLineWidth:25];
Can any one guide me for the same on how to delete particular selected dot.
Thanks in advance.
Upvotes: 0
Views: 202
Reputation: 689
If I understand your code fragment correctly, you are instantiating a new UIBezierPath object for every dot in the array.
So if you wish to erase a given dot, you will need the array of points to be mutable, and you would need to delete the actual path object from the array.
I suggest that you create a single UIBezierPath object and have an array that stores only the CGPoints.
Upvotes: 1