1

如何使用 uitouches 移动 CGRect?如果有人有想法请解释。

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

[self setNeedsDisplay];
4

2 回答 2

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...]

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

于 2012-08-28T11:17:54.667 回答
0

您需要重置矩形的框架:

[cropRect setFrame:CGRectMake(<new x coordinate>, <new y coordinate>, width, height)]
于 2012-08-28T07:08:36.917 回答