QQ侧滑,不全。。。。未完待续

pragma mark - 滑动手势

//滑动手势

  • (void) handlePan: (UIPanGestureRecognizer *)rec{

    CGPoint point = [rec translationInView:self.view];

    scalef = (point.x*speedf+scalef);

    //根据视图位置判断是左滑还是右边滑动
    if (rec.view.frame.origin.x>=0){
    rec.view.center = CGPointMake(rec.view.center.x + point.x*speedf,rec.view.center.y);
    rec.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1-scalef/1000,1-scalef/1000);
    [rec setTranslation:CGPointMake(0, 0) inView:self.view];

      righControl.view.hidden = YES;
      leftControl.view.hidden = NO;
    

    }
    else
    {
    rec.view.center = CGPointMake(rec.view.center.x + point.x*speedf,rec.view.center.y);
    rec.view.transform = CGAffineTransformScale(CGAffineTransformIdentity,1+scalef/1000,1+scalef/1000);
    [rec setTranslation:CGPointMake(0, 0) inView:self.view];

    righControl.view.hidden = NO;
    leftControl.view.hidden = YES;
}



//手势结束后修正位置
if (rec.state == UIGestureRecognizerStateEnded) {
    if (scalef>140*speedf){
        [self showLeftView];
    }
    else if (scalef<-140*speedf) {
        [self showRighView];        }
    else
    {
        [self showMainView];
        scalef = 0;
    }
}

}

你可能感兴趣的:(QQ侧滑,不全。。。。未完待续)