我有一个可以使用 UIPanGestureRecognizer 拖动的 UIView 对象,但我只希望它能够向上移动屏幕的 3/4。我不希望它被剪裁,而是要达到某个点并且不能被拖得更远。到目前为止,我所拥有的只允许它在 Y 轴上移动(这是所需的)。
- (IBAction)panGesture:(UIPanGestureRecognizer *)recognizer
{
CGPoint translation = [recognizer translationInView:self.view];
recognizer.view.center = CGPointMake(recognizer.view.center.x,
recognizer.view.center.y + translation.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:self.view];
}
谢谢你的帮助。