繁体   English   中英

如何使用UITouches移动CGRect?

[英]How can I move CGRect with UITouches?

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

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

[self setNeedsDisplay];

嗨,根据我的理解,您需要将裁剪后的图像移到另一个位置,因此需要在触摸内容中进行编码...

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

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

您需要重置矩形框:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM