No action is performed on UITableViewCell when blinking animation is implemented, it starts blinking that is fine but not clickable or swipable. I have tried some solutions but unable to fix it. Code is below.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell.backgroundColor = UIColor.colorWithHexString(hexStr: "#FDFAEB")
cell.blink()
return cell
}
Animation extension code:
extension UIView {
func blink() {
self.alpha = 0.5;
UIView.animate(withDuration: 0.7, //Time duration you want,
delay: 0.0,
options: [.curveEaseInOut, .autoreverse, .repeat],
animations: { [weak self] in self?.alpha = 1.0 },
completion: { [weak self] _ in self?.alpha = 0.8 })
}
}
Please tell me, what is the reason, and how can I fix this?
By default user interaction is disabled during animations. you need to add the .allowUserInteraction
option to your set of options.
(And note that if you're animating a view's position the user won't be able to tap on the view as it moves. Behind the scenes, a view jumps to it's destination position as soon as the animation begins. It only appears to move across the screen. If you want to handle tapping on a view as it moves across the screen it's a lot more complicated.)