I'm trying to rotate imageView and its UIImage together at the same time for better animation behavior it works well when I rotate for the first time, but when I rotate again the image doesn't change, what am I doing wrong?
let imageToRotate = UIImageView()
@objc func rotateImageButtonTapped() {
UIView.animate(withDuration: 0.3, animations: {
let rotatedTransform = imageToRotate.transform.rotated(by: CGFloat.pi / 2)
imageToRotate.transform = rotatedTransform
})
let image = imageToRotate.image
DispatchQueue.global(qos: .userInteractive).async {
let rotatedImage = image?.rotate(radians: .pi / 2)
page.isRotated = .rotated(rotatedImage: rotatedImage?.jpegData(compressionQuality: 1) ?? Data())
}
}