Iphone 画画后添加橡皮擦工具
我有绘画应用程序。当我点击按钮时,它会启动“绘制视图”,用户无法绘制。返回后,单击按钮,paintview将不会重置。如何在绘制后重置按钮单击中的视图 代码: 在viewcontroller代码中:Iphone 画画后添加橡皮擦工具,iphone,canvas,uiview,core-graphics,paint,Iphone,Canvas,Uiview,Core Graphics,Paint,我有绘画应用程序。当我点击按钮时,它会启动“绘制视图”,用户无法绘制。返回后,单击按钮,paintview将不会重置。如何在绘制后重置按钮单击中的视图 代码: 在viewcontroller代码中: PaintView *paint = [[PaintView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:paint]; [paint release]; 在…中,,, 为橡皮擦做一个切换,并按如下方
PaintView *paint = [[PaintView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:paint];
[paint release];
在…中,,,
为橡皮擦做一个切换,并按如下方式更改代码
if(togleEraser == NO)
{
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
}
else
{
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 20);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 50, 50));
}
最简单的方法就是删除视图并重新创建它。添加一些代码到您的问题,您的问题不清楚。。。重置视图取决于您编写了什么代码让用户在该视图上绘制
if(togleEraser == NO)
{
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
}
else
{
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 20);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 50, 50));
}