Pan Gesture Recognizer Does Not Work At All

I have animations on my 2 labels and I can't seem to click on them, I am not sure where the problem lies.

Code Block
override func viewDidLoad() {
    super.viewDidLoad()
    let tapGestureR = UITapGestureRecognizer(target: self, action: #selector(self.tapRev))
    revLabel.addGestureRecognizer(tapGestureR)
    revLabel.isUserInteractionEnabled = true
    let tapGestureP = UITapGestureRecognizer(target: self, action: #selector(self.tapPro))
    proLabel.addGestureRecognizer(tapGestureP)
    proLabel.isUserInteractionEnabled = true
    buttonNext.layer.cornerRadius = 10
    animatePro()
    animateRev()
  }


Code Block
   func animatePro() {
    UIView.animate(withDuration: 2, delay: 0, options: [.autoreverse], animations: {
      UIView.setAnimationRepeatCount(100)
      self.proLabel.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
    }){ (finished) in
        self.proLabel
          .transform = CGAffineTransform.identity
    }
  }
   
  func animateRev() {
    UIView.animate(withDuration: 2, delay: 0, options: .repeat, animations: {
      self.revLabel.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
    }){ (finished) in
      UIView.animate(withDuration: 2, delay: 0, options: .repeat, animations: {
        self.revLabel.transform = CGAffineTransform.identity
      })
    }
  }
   
   
  @objc func tapRev() {
    print("gesture rev fired")
    self.labelGC.text = "Ultimately, customers are our sources of \nrevenue , and financial stability."
    revLabel.alpha = 0
    proLabel.alpha = 0
  }
   
  @objc func tapPro() {
    print("gesture pro fired")
    self.labelGC.text = "Ultimately, customers are our sources of \nprofit , and financial stability."
    proLabel.alpha = 0
    revLabel.alpha = 0
  }



I mean UITapGestureRecognizer not Pan.
Please, once again, explain in detail what you expect and what you get.
Just posting code without explaining the use case is really bad practice (it saves you time, maybe, put is is a bad practice).

Is it the following ?
  • you animate the label

  • during animation, you tap the label

  • no reaction

If so, the explanation is that during animation the label is "replaced" by an image that is animated. So you don't have access to the label itself, but to an image ersatz.

Only when the animation ends does the label "come back" and responds once again to the taps.
So, if animation options is repeats, it never happens.

If that's the answer, don't forget to close the thread on this answer.
Don't forget either to close the other threads you left open.
Okay your solution does work but is there any way to tap on it if it repeats or would I have to change the UILabel to a UIView?
It is not a question of UIView or Label. The problem is the animation.

What you have to do to handle it is to replace the tapGesture by Tracking the UITouch.
Detect you touch in the label frame and act accordingly

Code Block
    override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { }
    override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool { }
    override func endTracking(_ touch: UITouch?, with event: UIEvent?) { }

Pan Gesture Recognizer Does Not Work At All
 
 
Q