長按是否可以在長時間按比例繪畫?因爲當我做長按手勢時,我想讓自己的線條變得更大,並使用該點來觸摸移動線。我希望這是有道理的,這是我的代碼。客觀C:製作點長按
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event//upon moving
{
UITouch *touch = [touches anyObject];
previousPoint2 = previousPoint1;
previousPoint1 = currentTouch;
currentTouch = [touch locationInView:self.view];
CGPoint mid1 = midPoint(previousPoint2, previousPoint1);
CGPoint mid2 = midPoint(currentTouch, previousPoint1);
UIGraphicsBeginImageContext(CGSizeMake(1024, 768));
[imgDraw.image drawInRect:CGRectMake(0, 0, 1024, 768)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context,kCGLineCapRound);
CGContextSetLineWidth(context, slider.value);
CGContextSetBlendMode(context, blendMode);
CGContextSetRGBStrokeColor(context,red, green, blue, 1);
CGContextBeginPath(context);
CGContextMoveToPoint(context, mid1.x, mid1.y);//Computation
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextStrokePath(context);
imgDraw.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsGetCurrentContext();
}
現在我該如何插入我的長按?
是你在UIView中聲明的代碼嗎?如果沒有使用drawinRec方法在「[self drawAtPoint:[recognitionizer locationInView:self.view] withRadius:radius]」中更改self,我應該怎麼做;「 – jrf 2012-07-25 08:31:28
不,我會在處理手勢的視圖控制器中聲明這一點。 drawAtPoint:withRadius方法只是我編寫的一個任意方法。你怎麼做你的繪畫? – 2012-07-25 08:34:53
我有一個「自我」的錯誤爲您的任意方法..我不知道我應該放在那裏。 – jrf 2012-07-25 09:28:53