1

我按照教程http://www.raywenderlich.com/21842/how-to-make-a-gesture-driven-to-do-list-app-part-13在表格视图单元格中执行手势识别。

一切都在 iOS6 中发生,但 iOS7 背景没有改变,它保持“透明”

有人有这个问题吗?

-(void)handlePan:(UIPanGestureRecognizer *)recognizer {
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        _originalCenter = self.center;
    }

    if (recognizer.state == UIGestureRecognizerStateChanged) {
        CGPoint translation = [recognizer translationInView:self];
        self.center = CGPointMake(_originalCenter.x + translation.x, _originalCenter.y);
        _telefonrarCompleteOnDragRelease = self.frame.origin.x > self.frame.size.width / 2;
        _emailOnDragRelease = self.frame.origin.x < -self.frame.size.width / 2;
        float cueAlpha = fabsf(self.frame.origin.x) / (self.frame.size.width / 2);
        _telefonar.alpha = cueAlpha;
        _email.alpha = cueAlpha;

        _email.backgroundColor = [UIColor colorWithRed:162/255.0 green:144/255.0 blue:97/255.0 alpha:1];
        _telefonar.backgroundColor = [UIColor colorWithRed:0/255.0 green:60/255.0 blue:100/255.0 alpha:1];

        _telefonar.textColor = [UIColor whiteColor];
        _email.textColor = [UIColor whiteColor];
    }

    if (recognizer.state == UIGestureRecognizerStateEnded) {
        CGRect originalFrame = CGRectMake(0, self.frame.origin.y,
                                          self.bounds.size.width, self.bounds.size.height);

        [UIView animateWithDuration:0.3
                             animations:^{
                                 self.frame = originalFrame;
                             }
         ];

        if (_emailOnDragRelease) {
            [self.delegate enviarEmail:self.funcionario];

        }
        if (_telefonrarCompleteOnDragRelease) {
            [self.delegate telefonar:self.funcionario];
        }
    }
}
4

0 回答 0