0

My goal is to build a custom cell that, when tapped, animates similar to Snapchat's. I have gotten the animation to work, but as a scroll more (after tap), the last selected cell continues to animate as I tap around the screen. Here's a video example

To get this animation, I am overriding the isSelected value in a custom cell class like so:

    override var isSelected: Bool {
        didSet {
            if isSelected {
                UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseOut, animations: {
                    self.transform = CGAffineTransform(scaleX: 0.95, y: 0.95)
                }, completion: { _ in
                    UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseOut, animations: {
                        self.transform = CGAffineTransform(scaleX: 1, y: 1)
                    }, completion: nil)
                })
            }
        }
    }

Please help me figure out why the last selected cell continues to animate even after the correct animation is completed.

Caleb Rudnicki
  • 345
  • 8
  • 17

0 Answers0