我正在使用以下代码来移动 UIView 中存在的 UIImageView。
- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
我想让 UIView 不会移动到父视图之外。此刻,图像视图能够在整个屏幕上移动。