iphone - 如何使用 UITouches 移动 CGRect?

标签 iphone objective-c ios

如何使用 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];
}

这里的 cloud 是 UIImageView,您可以将其作为裁剪后的图像....

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

希望对你有帮助...

关于iphone - 如何使用 UITouches 移动 CGRect?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12154088/

相关文章:

ios - 将原点移回原始位置

objective-c - NSConstantString 对象的唯一性

Android - 我可以在给定的标签上打开 Instagram 应用程序吗?

objective-c - 在 iPhone 项目中声明全局变量

objective-c - 如何在IOS中创建列表内列表

ios - 将字符串附加到 NSMutableDictionary 中的 NSMutableArray

ios - 确定 2 个字符串匹配概率的最佳实践

iphone - 在 2 个 ViewController 之间导航

objective-c - 使用 AVAudioplayer 在后台播放音乐

iphone - iPhone:无法在IOS5设备上使用IOS 4.3进行开发?