iOS滑动手势UIPanGestureRecognizer 注意事项

添加滑动手势

    //添加滑块

    UIPanGestureRecognizer *recognizerA = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];

    [recognizerA setMaximumNumberOfTouches:1];

  //滑块大小

    _AView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 100,150)];

    [_AView addGestureRecognizer:recognizerA];

 

/**

 * @brief 滑动模块

 */

#pragma mark --滑动模块

- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {

 

    //松开手指时判断滑动趋势让其计算滑动位子

    if (recognizer.state == UIGestureRecognizerStateEnded) {

        [self updateRelationships];

    }

}

/**

 * @brief 滑动大小

 */

#pragma mark --滑动大小

-(void)updateRelationships{

       NSLog(@"update-CGFloat_x::%f",AView.frame.origin.x);

    NSLog(@"update-CGFloat_x::%f",AView.frame.origin.y);

    

}

posted @ 2018-04-11 16:39  懒猫口米  阅读(291)  评论(0编辑  收藏  举报