The size of the image should depend on the time the button is clamped. My size changes at the beginning of the clamping and that's it, but it’s necessary that it be changed relative to the clamping time.
var startTime = Date() @IBOutlet weak var button: UIButton! @IBOutlet weak var heartImageView: UIImageView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let longPresss = UILongPressGestureRecognizer(target: self, action: #selector(longPress)) longPresss.delegate = self button.addGestureRecognizer(longPresss) } func longPress(gesture: UILongPressGestureRecognizer) { print(heartImageView.frame.size) if gesture.state == .began { let duration = Date().timeIntervalSince(startTime) print("duration \(Int(duration)) seconds") UIView.animate(withDuration: 0.5, animations: { if Int(duration) < 3 { self.heartImageView.transform = CGAffineTransform(scaleX: 1.35, y: 1.35) } else { self.heartImageView.alpha = 0 } }, completion: nil) } else if gesture.state == .ended { let duration = Date().timeIntervalSince(startTime) print("duration was \(Int(duration)) seconds") } }