Xcode 带有不可交叉边界的平移手势视图
要在没有图片的情况下轻松理解我的问题:Xcode 带有不可交叉边界的平移手势视图,xcode,uipangesturerecognizer,uipinchgesturerecognizer,Xcode,Uipangesturerecognizer,Uipinchgesturerecognizer,要在没有图片的情况下轻松理解我的问题: 我有自己的看法,颜色:黑色 我有一个与self.view一样大的视图,颜色:白色 我在视图1中有捏和平移手势 所以我需要的是缩放和滑动视图,但我不应该看到self.view的黑色。例如,view1的右边框可以移动到self.view的右边框。我希望这很容易理解。我现在所拥有的: - (void)handlePanGesture:(UIPanGestureRecognizer *)panGesture { CGPoint translation =
- (void)handlePanGesture:(UIPanGestureRecognizer *)panGesture {
CGPoint translation = [panGesture translationInView:panGesture.view.superview];
if (UIGestureRecognizerStateBegan == panGesture.state ||UIGestureRecognizerStateChanged == panGesture.state) {
panGesture.view.center = CGPointMake(panGesture.view.center.x + translation.x,
panGesture.view.center.y + translation.y);
[panGesture setTranslation:CGPointZero inView: self.view];
}
}
子类UIPangestureRecognitor并重写
TranslationView
以根据需要限制其值