2012-08-28 21 views
1

我怎樣才能使用uitouches移動CGRect?如果有人有想法,請解釋。如何使用UITouches移動CGRect?

if(areaSelected) 
     return; 
    UITouch *mytouch=[[touches allObjects] objectAtIndex:0]; 
    [myPath addLineToPoint:[mytouch locationInView:self]]; 

[self setNeedsDisplay]; 
+0

沒有明白你的問題...你想實現什麼? – IronManGill

+0

@Shehbaz是否想畫線? – Spynet

+0

我想移動我的矩形,這是正確的代碼CGRect cropRect = [myPath bounds]; \t \t // \t視網膜 \t \t cropRect = CGRectMake(cropRect.origin.x-10,cropRect.origin.y,cropRect.size.width * 1.5,cropRect.size.height * 1.5); –

回答

0

你需要重新設置矩形的框架:

[cropRect setFrame:CGRectMake(<new x coordinate>, <new y coordinate>, width, height)] 
1

喜按我的理解,你需要裁剪後的圖像移動到一個地方到另一個地方,所以你需要在代碼倒是東西...

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    UITouch *touch = [[event allTouches] anyObject]; 
    CGPoint location = [touch locationInView:touch.view]; 
    cloud.center = location; 
} 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 
    [self touchesBegan:touches withEvent:event]; 
} 

這裏的雲是UIImageView的你可以把它作爲裁剪圖像....

cloud.image=croppedImage; //[you must assign this first...] 

我希望它可以幫助你...

+0

thanx spynet它真的幫助我aloot :) –

+0

酷哥們不斷提問... – Spynet