嗨朋友们,我正在创建 ipad 应用程序,我在 UIScrollView 中使用 UIImageView。因此,当我缩放图像并尝试绘制一些东西时,它并没有在我触摸的那个点上绘制。我放大了多少它在绘图上有所不同,并在左上角而不是中心创建图像。伙计们建议我。这是我的代码
if (isFreeHand==YES) {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self];
self.frame = CGRectIntegral(self.frame);
UIGraphicsBeginImageContextWithOptions(self.frame.size, self.opaque, 0.0);
[self.tempDrawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x-mWidht, lastPoint.y-mHeight);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x-mWidht, currentPoint.y-mHeight);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brush );
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), red, green, blue, 1.0);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);
CGContextStrokePath(UIGraphicsGetCurrentContext());
self.tempDrawImage.image = UIGraphicsGetImageFromCurrentImageContext();
[self.tempDrawImage setAlpha:opacity];
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}