拖拽手势能否 当拖动的时候能否获得两个相邻手势点之间的距离呢  是不是可以设置一个中间变量来计算得到。

解决方案 »

  1.   

    如果你用使用touchesBegain等方法实现拖拽,则可以如下实现:
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        // 记录开始时的位置,_ptMarked需要被定义为成员变量
        _ptMarked = [[touches anyObject] locationInView:self];
    }-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        CGPoint ptCurrent = [touches anyObject] locationInView:self];   // 计算当前触点和初始触点间的距离
        CGFloat distance = sqrt(pow((ptCurrent.x-_ptMarked.x),2.0)+pow((ptCurrent.y-_ptMarked.y), 2.0));
    }