将屏幕区域限制为UIPanGestureRecognizer

时间:2013-08-25 15:15:24

标签: ios objective-c uipangesturerecognizer

我有3个UIViews,当我的手指在屏幕上下移动时会改变它们的高度,每个都是这样的:

- (void)pan:(UIPanGestureRecognizer *)aPan; {
    CGPoint currentPoint = [aPan locationInView:self.view];

    currentPoint.y -= 80;

    if (currentPoint.y < 0) {
        currentPoint.y = 0;
    }
    else if (currentPoint.y > 240) {
        currentPoint.y = 240;
    }

    currentPoint.y = 240.0 - currentPoint.y;

    [UIView animateWithDuration:0.01f
                     animations:^{
                         CGRect oldFrame = secondBar.frame;
                         secondBar.frame = CGRectMake(oldFrame.origin.x, (oldFrame.origin.y - (currentPoint.y - secondBar.frame.size.height)), oldFrame.size.width, (currentPoint.y));
                     }];
}

然而,在屏幕上移动我的手指会移动所有三个视图。如何更改它,以便当我的手指在屏幕的某个部分/特定视图上时,它只会移动该视图?

0 个答案:

没有答案
相关问题