-1

我正在尝试开发一个着色应用程序。我想从一个空白画布开始,当用户使用触摸颜色时,我只想显示彩色图像的那些触摸区域。我该如何做到这一点?任何帮助都会对我有很大帮助。

4

1 回答 1

0

可能这会帮助你开始

UITouch *touch = [touches anyObject];   

    CGPoint currentPoint = [touch locationInView:drawImage];


    UIGraphicsBeginImageContext(drawImage.frame.size);

    [drawImage.image drawInRect:CGRectMake(0, 0, drawImage.frame.size.width, drawImage.frame.size.height)];

    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);

    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), size);


      CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), r, g, b, a);


    CGContextBeginPath(UIGraphicsGetCurrentContext());

    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);

    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);

    CGContextStrokePath(UIGraphicsGetCurrentContext());

    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

虽然我还没有尝试过,但在 SO question 上发现它对你的要求很好

于 2012-04-14T07:58:03.380 回答