【发布时间】:2012-07-04 11:23:21
【问题描述】:
在我的应用程序中,我有两个视图,一个在另一个之上。在下面的视图中,我有一个捕获的图像,在上面的视图中我放置了一个图像。如果用户需要对上面的图像进行一些更改,我会为他们提供删除图像的选项。
一切正常,问题是如果我试图擦除图像,它似乎是一个损坏的图像。图像不会以温和的方式被删除。当我擦除它看起来像下面的。
我希望它如下
如何做到这一点,请帮助我
以下是我的代码:
UIGraphicsBeginImageContext(frontImage.frame.size);
[frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 50, 50));
CGContextStrokePath(UIGraphicsGetCurrentContext());
frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
【问题讨论】:
-
使用这行连接端:CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
-
感谢您的回复,我在这里使用了这些代码行,但现在我没有得到。在上面我添加了我已经实现的代码
-
谢谢,但我在边界框中使用 ccsprite 在 cocos2d 中擦除游戏中的图像,所以请...帮助
标签: objective-c opengl-es quartz-graphics core-image