0

我想仅在 UIPinchGesture “检测到捏合”时将我的视图限制为缩放。这是我的代码,它不起作用,因为它不会将 UIPinchGesture 限制为仅捏合而不是捏合,它会通过捏合和捏合检测到。提前致谢!丹尼尔

-(void)PinchOutGesture {

UIPinchGestureRecognizer *longPress_gr1 = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(doAction1:)];

//pinch out//
if(longPress_gr1.scale > 1) {


     [View addGestureRecognizer:longPress_gr1];
    //something happens
}


//Pinch in
if(longPress_gr1.scale < 1) {

    View = nil;
    //nothing happens

  }

}



- (void)doAction1:(UIPinchGestureRecognizer *)recognizer {


    View.userInteractionEnabled = NO;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.25];
    [UIView setAnimationDelay:0.0];

    View.frame = CGRectMake(30, 64, 260, 334);
    View.alpha = 0.5;


    [UIView commitAnimations];

}
4

0 回答 0