Pulsante iOS non selezionabile durante l'animazione


0 Answers

Prova questo ti aiuterà

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
      UITouch *touch = [touches anyObject];
      CGPoint touchLocation = [touch locationInView:self.view];
      for (UIButton *button in self.arrBtn)
      {
          if ([button.layer.presentationLayer hitTest:touchLocation])
         {
        // This button was hit whilst moving - do something with it here
            [button setBackgroundColor:[UIColor cyanColor]];
             NSLog(@"Button Clicked");
             break;
         }
      }
}
Question

Quando ho aggiunto l'animazione al mio pulsante utilizzando un metodo di categoria, quindi non posso fare clic su quel pulsante, sembra che sia disabilitato:

[_compassCalibrateButton pulse:1.5 continuously:YES];
_compassCalibrateButton.userInteractionEnabled=YES;

Ho una categoria UIView che contamina questo:

- (void)pulse:(float)secs continuously:(BOOL)continuously {
    [UIView animateWithDuration:secs/2 
                          delay:0.0 
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{
                         // Fade out, but not completely
                         self.alpha = 0.3;
                     }
                     completion:^(BOOL finished) { 
                         [UIView animateWithDuration:secs/2 
                                               delay:0.0 
                                             options:UIViewAnimationOptionCurveLinear
                                          animations:^{
                                              // Fade in
                                              self.alpha = 1.0;
                                          }
                                          completion:^(BOOL finished) { 
                                              if (continuously) {
                                                  [self pulse:secs continuously:continuously];
                                              }
                                          }];
                     }];
}



Related