Iphone 屏幕坐标与CGAffineTransform
我正在使用手势触摸功能旋转调整图像大小。现在我想做的是,当图像到达某个X,Y点时,它会从视图中消失 当我与CGpoint合作时,效果很好 如何从CGT变换矩阵中获取(x y)坐标 我当前使用的代码是Iphone 屏幕坐标与CGAffineTransform,iphone,objective-c,Iphone,Objective C,我正在使用手势触摸功能旋转调整图像大小。现在我想做的是,当图像到达某个X,Y点时,它会从视图中消失 当我与CGpoint合作时,效果很好 如何从CGT变换矩阵中获取(x y)坐标 我当前使用的代码是 - (void)updateOriginalTransformForTouches:(NSSet *)touches { if ([touches count] > 0) { CGAffineTransform incrementalTransform = [self
- (void)updateOriginalTransformForTouches:(NSSet *)touches
{
if ([touches count] > 0) {
CGAffineTransform incrementalTransform = [self incrementalTransformWithTouches:touches];
[self setConstrainedTransform:CGAffineTransformConcat(originalTransform, incrementalTransform)];
originalTransform = self.transform;
}
}
// At start, store the touch begin points and set an original transform
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[[self superview] bringSubviewToFront:self];
NSMutableSet *currentTouches = [[[event touchesForView:self] mutableCopy] autorelease];
[currentTouches minusSet:touches];
if ([currentTouches count] > 0) {
[self updateOriginalTransformForTouches:currentTouches];
[self cacheBeginPointForTouches:currentTouches];
}
[self cacheBeginPointForTouches:touches];
}
// During movement, update the transform to match the touches
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGAffineTransform incrementalTransform = [self incrementalTransformWithTouches:[event touchesForView:self]];
[self setConstrainedTransform:CGAffineTransformConcat(originalTransform, incrementalTransform)];
NSLog(@"%f",incrementalTransform.tx);
NSLog(@"%f",incrementalTransform.ty);
if (incrementalTransform.tx == 44 && incrementalTransform.ty == 281) {
NSLog(@"dvvd");
}
}
// Finish by removing touches, handling double-tap requests
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self updateOriginalTransformForTouches:[event touchesForView:self]];
[self removeTouchesFromCache:touches];
for (UITouch *touch in touches) {
if (touch.tapCount >= 2) {
[self.superview bringSubviewToFront:self];
}
}
NSMutableSet *remainingTouches = [[[event touchesForView:self] mutableCopy] autorelease];
[remainingTouches minusSet:touches];
[self cacheBeginPointForTouches:remainingTouches];
}// Redirect cancel to ended
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesEnded:touches withEvent:event];
}
您是否询问如何确定视图的矩形在当前坐标系中的位置?如果是,
CGRect transformedFrame = CGRectApplyAffineTransform(self.frame, incrementalTransform);
好的,我想回答我自己的问题 我一直在寻找各种方法来完成我的任务,昨晚我找到了一些对我的任务更方便的方法 我使用的链接也是如此
它对我有用我进一步向你介绍了它。。。我的屏幕上几乎没有图像(没有UIImageView),这些图像可以调整大小和旋转(使用我提供的代码),现在我想做的是删除视图中的任何图像。为了实现这一点,用户必须将其拖动到某个位置,在该位置将有垃圾箱的另一个图像(将固定到视图中)(假设该图像的位置为(100100)),如果用户将该图像拖动到该坐标,则图像将从视图中删除///