I have a function that animates the movement of a UIImageView from one set of coordinates to another on the opposite side of the screen. During the animation I want to document where the image is when I tap on it. When I make a call like so I get the destination location not the current location:
var rippleImage = UIImageView()
//example animation block
UIView.animate(withDuration: 6, delay: 0.0, options: [.curveLinear, .allowUserInteraction], animations: {
self.rippleImage.frame = CGRect(x: (xaxis - 500) , y: (yaxis - 500) , width: (self.rippleImage.frame.width + 1000), height: (self.rippleImage.frame.height + 1000))
self.rippleImage.alpha = 0.1
}, completion: nil )
//sample button click function to capture location
@objc func pianoKeyButtonTapped(sender: UIImageView) -> [String] {
// get and animate current ripple
let currentRippleLocation = self.rippleImage.frame
print(currentRippleLocation)
}
In every case I get the same destination location like so:
(-342.5, 67.0, 1060.0, 1060.0)