I currently have an imageView which I can drag around the screen using a panGestureRecognizer and the following method:
- (void)panDetected:(UIPanGestureRecognizer *)panRecognizer {
CGPoint translation = [panRecognizer translationInView:self.view];
CGPoint imageViewPosition = self.imageView.center;
imageViewPosition.x += translation.x;
imageViewPosition.y += translation.y;
self.imageView.center = imageViewPosition;
[panRecognizer setTranslation:CGPointZero inView:self.view];
}
Currently the image can be dragged off the screen so that it is only partially visible, I would like to know if there is a way to stop the image at the edge of the screen? I know it should be possible, I am just struggling with the logic.