0

How can I get an image to follow a touch using CGAffineTransformMakeTranslation? It seems like CGAffineTransformMakeTranslation is only iterating the position of the image that is why it doesnt follow the touch on the view.

SleepNot
  • 2,982
  • 10
  • 43
  • 72

2 Answers2

0

Please paste some code. Also, why not modify the center of the UIImageView and set it equal to the point of the touch? It's easier to use that if you simply want an image following your taps.

Idles
  • 1,131
  • 5
  • 9
  • It is because I am creating a small square image in the middle of a shape drawn using UIBezierPath. When I touch the square image and move my touch, it should follow my touch and also the shape should follow my touch as well. – SleepNot Jun 19 '13 at 09:30
  • Can't you wrap all of those things in a `UIView`, and then move that `UIView` using its `center` property? That way everything in the outer UIView should move together. – Idles Jun 19 '13 at 09:32
0

Well, if you just want the square to follow your touch, I'd use a panGestureRecognizer:

- (void)resizeViewPanGesture:(UIPanGestureRecognizer *)recognizer {
    if ([recognizer state] == UIGestureRecognizerStateChanged) {
        //Get latest location of touch
        smallSquareView.center = [recognizer locationInView:self.superview];
    }
}

I'm not sure what you want from your comment, could you please share some images of what you're trying to achieve?

Efesus
  • 197
  • 2
  • 17