UIPanGestureRecognizer:手指下的偏移视图

时间:2014-07-28 06:19:16

标签: ios objective-c uipangesturerecognizer

我有一个带有一些UIViews的scrollView作为我拖动的子视图。问题是子视图相当小,拖动它们时,你看不到它们,因为手指挡住了。

拖动时如何向上偏移视图?

由于

if (recognizer.state == UIGestureRecognizerStateChanged)
{
    CGPoint translation = [recognizer translationInView:self];
    draggingView.center = CGPointMake(draggingView.center.x + translation.x,
                                      draggingView.center.y + translation.y);

    [recognizer setTranslation:CGPointZero inView:self];
}

1 个答案:

答案 0 :(得分:1)

尝试以下代码  CGPoint touchPoint = [recognizer locationInView:self]; 尝试更改touchPoint