Я использую функцию сенсорного жеста, чтобы повернуть изменить размер моего изображения.Теперь я хочу, чтобы, когда изображение достигло определенной точки X, Y, оно исчезло из вида.
Когда я работал с CGpoint, он работал нормально.
Как получить координаты (xy) из матрицы CGTransform
Код, который я сейчас использую, равен
- (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];
}