2012-02-13 93 views
1

我正在製作一個觸摸繪製應用程序,一切工作都很好,但是當我旋轉我的iPad時,我觸摸的線條位於手指上方5釐米處。旋轉時的觸摸繪製

iv使用google搜索了很多,試圖找出如何在旋轉時更改x &。

你們能幫助我嗎?

我繪製它的代碼如下:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

mouseSwiped = YES; 

UITouch *touch = [touches anyObject]; 
CGPoint currentPoint = [touch locationInView:self.view]; 
currentPoint.y -= -20; 


UIGraphicsBeginImageContext(self.view.frame.size); 

[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
CGContextSaveGState(UIGraphicsGetCurrentContext()); 
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES); 
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy); 
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), f5); 
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), f1, f2, f3, f4); 
CGContextBeginPath(UIGraphicsGetCurrentContext()); 
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); 
CGContextStrokePath(UIGraphicsGetCurrentContext()); 
drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
CGContextRestoreGState(UIGraphicsGetCurrentContext()); 
UIGraphicsEndImageContext(); 

lastPoint = currentPoint; 


mouseMoved++; 

if (mouseMoved == 10) { 
    mouseMoved = 0;}} 

回答

1

我是用我的appDelegate和幀邊界在我的抽獎代碼... 我改成了:

UIGraphicsBeginImageContext(self.view.bounds.size); 

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