【发布时间】:2016-04-08 08:09:37
【问题描述】:
我在subview 中有一个UILabel,在UILabel 上有一个panGesture 和pinchGesture。截至目前,我可以将UILabel 移动到所有视图中。我希望这个UILabel 留在subView 的区域内。我将如何做到这一点?
- (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];
}
}
在这一行中,
CGPoint translation = [panGesture translationInView:panGesture.view.superview];
它正在将其设置为 superView,我正在尝试将其设置为我的 subView,但我似乎无法弄清楚。
【问题讨论】:
标签: ios objective-c subview uipangesturerecognizer